node.js安装gitbook报错

已经安装有node.js的情况下,下载gitbook

npm install -g gitbook-cli
gitbook init

如下图报错


image.png

解决方法:
1.先使用淘宝镜像

npm config set registry https://registry.npm.taobao.org

2.再检查是不是淘宝镜像

npm config get registry

3.重新安装

gitbook init
image.png

继续报错

TypeError: cb.apply is not a function
    at C:\Users\UID\AppData\Roaming\npm\node_modules\gitbook-cli\node_modules\npm\node_modules\graceful-fs\polyfills.js:287:18
    at FSReqCallback.oncomplete (node:fs:199:5)

报287行有错


image.png

解决方法:
1.将使用到这个回调函数的地方注释掉
2.按报错的路径,找到polyfills.js文件,注释掉62,63,64行,如果行数不对,请注意找的路径是否正确,之前我找错过目录一次


image.png

3.最后再次执行gitbook init,就成功了

这种方法很简单粗暴,但是只是简单使用一下文档,就不用去换node.js版本去适应gitbook了

你可能感兴趣的:(node.js安装gitbook报错)