Gitbook出现TypeError: cb.apply is not a function

问题现象

$ gitbook -V
CLI version: 2.3.2
Installing GitBook 3.2.3
C:\Users\91613\AppData\Roaming\npm\node_modules\gitbook-cli\node_modules\npm\node_modules\graceful-fs\polyfills.js:287
      if (cb) cb.apply(this, arguments)
                 ^

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

原因

The problem is that GitBook is still using outdated dependencies that pull in versions of graceful-fs without the fix.

解决

进入C:\Users\91613\AppData\Roaming\npm\node_modules\gitbook-cli\node_modules\npm\node_modules\后,运行如下命令即可。路径可查看错误提示。

$ npm install graceful-fs@latest --save

其他方法

找到错误提示中的polyfills.js目录,使用开发工具打开编辑polyfills.js文件,找statFix函数,在62-64行,将其屏蔽掉。
Gitbook出现TypeError: cb.apply is not a function_第1张图片

安装老版本的nodejs

https://nodejs.org/zh-cn/download/releases

安装老版本gitbook

npm install [email protected] --global

你可能感兴趣的:(文档管理,npm,前端,node.js)