一段时间不用gitbook打开进行 gitbook 启动服务 gitbook serve 报错了
按照官网内容重装了一下还是报错如下
Live reload server started on port: 35729
Press CTRL+C to quit ...
/usr/local/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 /usr/local/lib/node_modules/gitbook-cli/node_modules/npm/node_modules/graceful-fs/polyfills.js:287:18
at FSReqCallback.oncomplete (node:fs:196: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使用地址: http://gitbook.zhangjikai.com/installation.html