已經(jīng)安裝有node.js的情況下,下載gitbook
npm install -g gitbook-cli
gitbook init
如下圖報(bào)錯(cuò)

image.png
解決方法:
1.先使用淘寶鏡像
npm config set registry https://registry.npm.taobao.org
2.再檢查是不是淘寶鏡像
npm config get registry
3.重新安裝
gitbook init

image.png
繼續(xù)報(bào)錯(cuò)
TypeError: cb.apply is not a function
at C:\Users\UID\AppData\Roaming\npm\node_modules\gitbook-cli\node_modules\npm\node_modules\graceful-fs\polyfills.js:287:18
at FSReqCallback.oncomplete (node:fs:199:5)
報(bào)287行有錯(cuò)

image.png
解決方法:
1.將使用到這個(gè)回調(diào)函數(shù)的地方注釋掉
2.按報(bào)錯(cuò)的路徑,找到polyfills.js文件,注釋掉62,63,64行,如果行數(shù)不對(duì),請(qǐng)注意找的路徑是否正確,之前我找錯(cuò)過目錄一次

image.png
3.最后再次執(zhí)行g(shù)itbook init,就成功了
這種方法很簡(jiǎn)單粗暴,但是只是簡(jiǎn)單使用一下文檔,就不用去換node.js版本去適應(yīng)gitbook了