gitbook:gitbook-cli\node_modules\npm\node_modules\graceful-fs\polyfills.js

gitbook:gitbook-cli\node_modules\npm\node_modules\graceful-fs\polyfills.js


!.2021年07月21日二次修订

不建议使用node-v12.22.3,可能执行gitbook serve仍有问题。

建议:使用node-v9.11.2。

参考:https://blog.csdn.net/test1280/article/details/118968549


1.异常

执行gitbook init报错:

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 init过程:

EB@DESKTOP-K45IA6V MINGW64 ~/Desktop
$ mkdir test1280-gitbook

EB@DESKTOP-K45IA6V MINGW64 ~/Desktop
$ cd test1280-gitbook/

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)

2.环境

node version

EB@DESKTOP-K45IA6V MINGW64 ~/Desktop/test1280-gitbook
$ node -v
v14.17.3

npm version

EB@DESKTOP-K45IA6V MINGW64 ~/Desktop/test1280-gitbook
$ npm -v
6.14.13

3.解决

卸载当前高版本的nodejs,安装低版本的nodejs。

在这里插入图片描述

nodejs历史版本下载:https://nodejs.org/dist/

在这里插入图片描述

我选择的是node-v12.22.3-x64.msi:

https://nodejs.org/dist/latest-v12.x/node-v12.22.3-x64.msi

在这里插入图片描述

重新安装nodejs。

重试:

EB@DESKTOP-K45IA6V MINGW64 ~/Desktop/test1280-gitbook
$ node -v
v12.22.3

EB@DESKTOP-K45IA6V MINGW64 ~/Desktop/test1280-gitbook
$ npm -v
6.14.13

EB@DESKTOP-K45IA6V MINGW64 ~/Desktop/test1280-gitbook
$ npm install -g gitbook-cli
C:\Users\EB\AppData\Roaming\npm\gitbook -> C:\Users\EB\AppData\Roaming\npm\node_modules\gitbook-cli\bin\gitbook.js
+ gitbook-cli@2.3.2
updated 3 packages in 10.212s

EB@DESKTOP-K45IA6V MINGW64 ~/Desktop/test1280-gitbook
$ gitbook init
warn: no summary file in this book
info: create README.md
info: create SUMMARY.md
info: initialization is finished

EB@DESKTOP-K45IA6V MINGW64 ~/Desktop/test1280-gitbook
$ ll
total 2
-rw-r--r-- 1 EB 197609 16  7月 21 14:45 README.md
-rw-r--r-- 1 EB 197609 40  7月 21 14:45 SUMMARY.md

gitbook init成功。


4.其他

如果遇到报错:

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

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

EB@DESKTOP-K45IA6V MINGW64 ~/Desktop/test1280-gitbook
$ ll
total 1
-rw-r--r-- 1 EB 197609 16  7月 21 14:37 README.md

同上,卸载高版本的nodejs,安装低版本的nodejs,重试。


5.参考

1.https://blog.csdn.net/Java_stud/article/details/118493661
2.https://blog.csdn.net/withoutBugs/article/details/105869042
3.https://stackoverflow.com/questions/64211386/gitbook-cli-install-error-typeerror-cb-apply-is-not-a-function-inside-graceful
4.https://blog.csdn.net/Ming_360/article/details/109685876
5.https://lgl88911.gitee.io/2020/11/08/Windows下Gitbook安装/
6.https://nodejs.org/en/download/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值