gitbook出现TypeError: cb.apply is not a function解决办法

Posted dingwen_blog

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了gitbook出现TypeError: cb.apply is not a function解决办法相关的知识,希望对你有一定的参考价值。

执行gitbook -V的时候出现如下错误

[root@pes nodejs]# gitbook -V
CLI version: 2.3.2
Installing GitBook 3.2.3
/data/soft/nodejs/lib/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 /data/soft/nodejs/lib/node_modules/gitbook-cli/node_modules/npm/node_modules/graceful-fs/polyfills.js:287:18
    at FSReqCallback.oncomplete (fs.js:169:5)

打开polyfills.js文件,找到这个函数

function statFix (orig) 
  if (!orig) return orig
  // Older versions of Node erroneously returned signed integers for
  // uid + gid.
  return function (target, cb) 
    return orig.call(fs, target, function (er, stats) 
      if (!stats) return cb.apply(this, arguments)
      if (stats.uid < 0) stats.uid += 0x100000000
      if (stats.gid < 0) stats.gid += 0x100000000
      if (cb) cb.apply(this, arguments)
    )
  

在第62-64行调用了这个函数,把这三行代码注释掉就解决报错了

fs.stat = statFix(fs.stat)
fs.fstat = statFix(fs.fstat)
fs.lstat = statFix(fs.lstat)

以上是关于gitbook出现TypeError: cb.apply is not a function解决办法的主要内容,如果未能解决你的问题,请参考以下文章

gitbook init出现TypeError: cb.apply is not a function解决办法

gitbook init出现TypeError: cb.apply is not a function解决办法

『开发技巧』gitbook从入门到放弃(指令错误解决)

『开发技巧』gitbook从入门到放弃(指令错误解决)

Gitbook 生成 pdf 中文字体错乱问题解决办法

gitbook新版本“gitbook build“命令导出的html不能跳转的解决办法