gitbook:node_modules\npm\node_modules\graceful-fs\polyfills.js:287
2021/7/21 17:06:09
本文主要是介绍gitbook:node_modules\npm\node_modules\graceful-fs\polyfills.js:287,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
gitbook:node_modules\npm\node_modules\graceful-fs\polyfills.js:287
1.异常
执行gitbook serve错误:
C:\Users\EB\AppData\Roaming\npm\node_modules\gitbook-cli\node_modules\npm\node_modules\graceful-fs\polyfills.js:287 if (cb) cb.apply(this, arguments) ^
执行gitbook serve过程:
EB@DESKTOP-K45IA6V MINGW64 ~/Desktop/test1280-gitbook $ gitbook serve Live reload server started on port: 35729 Press CTRL+C to quit ... C:\Users\EB\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\EB\AppData\Roaming\npm\node_modules\gitbook-cli\node_modules\npm\node_modules\graceful-fs\polyfills.js:287:18 at FSReqCallback.oncomplete (fs.js:169:5)
2.环境
node
EB@DESKTOP-K45IA6V MINGW64 ~/Desktop/test1280-gitbook $ node -v v12.22.3
npm
EB@DESKTOP-K45IA6V MINGW64 ~/Desktop/test1280-gitbook $ npm -v 6.14.13
3.原因
参考:
https://stackoverflow.com/questions/64211386/gitbook-cli-install-error-typeerror-cb-apply-is-not-a-function-inside-graceful
The issue was originally a problem inside graceful-fs but they solved it in this commit I believe.
The problem is that GitBook is still using outdated dependencies that pull in versions of graceful-fs without the fix.
按照上面的解释,只需要更新graceful-fs版本即可。
4.解决
我的gitbook是global安装:npm install -g gitbook-cli
根据报错信息:
C:\Users\EB\AppData\Roaming\npm\node_modules\gitbook-cli\node_modules\npm\node_modules\graceful-fs\polyfills.js:287
if (cb) cb.apply(this, arguments)
我切换到目录:
C:\Users\EB\AppData\Roaming\npm\node_modules\gitbook-cli\node_modules\npm\node_modules\
执行命令:
EB@DESKTOP-K45IA6V MINGW64 ~/AppData/Roaming/npm/node_modules/gitbook-cli/node_modules/npm/node_modules $ npm install graceful-fs@latest --save npm notice created a lockfile as package-lock.json. You should commit this file. + graceful-fs@4.2.6 updated 1 package in 1.308s
更新成功(graceful-fs)。
再次尝试:
EB@DESKTOP-K45IA6V MINGW64 ~/Desktop/test1280-gitbook $ gitbook serve Live reload server started on port: 35729 Press CTRL+C to quit ... info: 7 plugins are installed info: loading plugin "livereload"... OK info: loading plugin "highlight"... OK info: loading plugin "search"... OK info: loading plugin "lunr"... OK info: loading plugin "sharing"... OK info: loading plugin "fontsettings"... OK info: loading plugin "theme-default"... OK info: found 16 pages info: found 14 asset files _stream_readable.js:637 if (state.pipesCount === 1) { ^ TypeError: Cannot read property 'pipesCount' of undefined at ReadStream.Readable.pipe (_stream_readable.js:637:13) at C:\Users\EB\.gitbook\versions\3.2.3\node_modules\cpr\lib\index.js:163:22 at callback (C:\Users\EB\AppData\Roaming\npm\node_modules\gitbook-cli\node_modules\npm\node_modules\graceful-fs\polyfills.js:299:20) at FSReqCallback.oncomplete (fs.js:168:21)
仍然报错!
最终解决:
参考:https://blog.csdn.net/test1280/article/details/118961808
降级nodejs版本为:node-v9.11.2-x64.msi
再次重试:
EB@DESKTOP-K45IA6V MINGW64 ~/Desktop/test1280-gitbook $ gitbook init info: create SUMMARY.md info: initialization is finished EB@DESKTOP-K45IA6V MINGW64 ~/Desktop/test1280-gitbook $ gitbook serve Live reload server started on port: 35729 Press CTRL+C to quit ... info: 7 plugins are installed info: loading plugin "livereload"... OK info: loading plugin "highlight"... OK info: loading plugin "search"... OK info: loading plugin "lunr"... OK info: loading plugin "sharing"... OK info: loading plugin "fontsettings"... OK info: loading plugin "theme-default"... OK info: found 16 pages info: found 14 asset files info: >> generation finished with success in 1.2s ! Starting server ... Serving book on http://localhost:4000
成功启动:
5.后记
5.1.case1
node-v14.17.3-x64.msi
gitbook init报错:
EB@DESKTOP-K45IA6V MINGW64 ~/Desktop/test1280-gitbook $ gitbook init Installing GitBook 3.2.3 C:\Users\EB\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\EB\AppData\Roaming\npm\node_modules\gitbook-cli\node_modules\npm\node_modules\graceful-fs\polyfills.js:287:18 at FSReqCallback.oncomplete (fs.js:193:5)
gitbook init报错(或):
EB@DESKTOP-K45IA6V MINGW64 ~/Desktop/test1280-gitbook $ gitbook init warn: no summary file in this book info: create README.md info: create SUMMARY.md TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received an instance of Promise
5.2.case2
node-v12.22.3-x64.msi
gitbook serve报错:
EB@DESKTOP-K45IA6V MINGW64 ~/Desktop/test1280-gitbook $ gitbook serve Live reload server started on port: 35729 Press CTRL+C to quit ... C:\Users\EB\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\EB\AppData\Roaming\npm\node_modules\gitbook-cli\node_modules\npm\node_modules\graceful-fs\polyfills.js:287:18 at FSReqCallback.oncomplete (fs.js:169:5)
更新graceful-fs,仍然报错:
EB@DESKTOP-K45IA6V MINGW64 ~/Desktop/test1280-gitbook $ gitbook serve Live reload server started on port: 35729 Press CTRL+C to quit ... info: 7 plugins are installed info: loading plugin "livereload"... OK info: loading plugin "highlight"... OK info: loading plugin "search"... OK info: loading plugin "lunr"... OK info: loading plugin "sharing"... OK info: loading plugin "fontsettings"... OK info: loading plugin "theme-default"... OK info: found 16 pages info: found 14 asset files _stream_readable.js:637 if (state.pipesCount === 1) { ^ TypeError: Cannot read property 'pipesCount' of undefined at ReadStream.Readable.pipe (_stream_readable.js:637:13) at C:\Users\EB\.gitbook\versions\3.2.3\node_modules\cpr\lib\index.js:163:22 at callback (C:\Users\EB\AppData\Roaming\npm\node_modules\gitbook-cli\node_modules\npm\node_modules\graceful-fs\polyfills.js:299:20) at FSReqCallback.oncomplete (fs.js:168:21)
5.3.case3
node-v9.11.2-x64.msi
成功。
6.参考
https://blog.csdn.net/test1280/article/details/118961808
这篇关于gitbook:node_modules\npm\node_modules\graceful-fs\polyfills.js:287的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-12-21Vue3教程:新手入门到实践应用
- 2024-12-21VueRouter4教程:从入门到实践
- 2024-12-20Vue3项目实战:从入门到上手
- 2024-12-20Vue3项目实战:新手入门教程
- 2024-12-20VueRouter4项目实战:新手入门教程
- 2024-12-20如何实现JDBC和jsp的关系?-icode9专业技术文章分享
- 2024-12-20Vue项目中实现TagsView标签栏导航的简单教程
- 2024-12-20Vue3入门教程:从零开始搭建你的第一个Vue3项目
- 2024-12-20从零开始学习vueRouter4:基础教程
- 2024-12-20Vuex4课程:新手入门到上手实战全攻略