编程语言
首页 > 编程语言> > gitbook:gitbook-cli\node_modules\npm\node_modules\graceful-fs\polyfills.js

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

作者:互联网

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


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%E4%B8%8BGitbook%E5%AE%89%E8%A3%85/
6.https://nodejs.org/en/download/

标签:node,npm,modules,Desktop,gitbook,EB
来源: https://blog.csdn.net/test1280/article/details/118961808