1. 安装nodejs
[root@prd-gitbook ~]# dnf -y install nodejs
[root@prd-gitbook ~]# node -v
v18.16.0
[root@prd-gitbook ~]# npm -v
9.5.1
[root@prd-gitbook ~]# npm config set registry https://registry.npm.taobao.org -g
[root@prd-gitbook ~]# npm config get registry
https://registry.npm.taobao.org/
2. 安装gitbook
[root@prd-gitbook ~]# npm install gitbook-cli -g
[root@prd-gitbook ~]# gitbook -V
然后,请耐心地等待。。。
NOTE
报错1:
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:209:5)
解决方法:
vim /usr/local/lib/node_modules/gitbook-cli/node_modules/npm/node_modules/graceful-fs/polyfills.js
注释以下三行:
// fs.stat = statFix(fs.stat)
// fs.fstat = statFix(fs.fstat)
// fs.lstat = statFix(fs.lstat)