gitbook安装

本文在centos7下安装,注:nodejs v12版本会出错,还没安装跳过此步骤,往下看。

[root]# node -v
v12.22.1
[root]# npm -v
6.14.12
[root]# npm install gitbook-cli -g
/root/.nvm/versions/node/v12.22.1/bin/gitbook -> /root/.nvm/versions/node/v12.22.1/lib/node_modules/gitbook-cli/bin/gitbook.js
+ [email protected]
added 578 packages from 672 contributors in 26.373s

查看版本时出现TypeError: cb.apply is not a function

[[email protected] home]# gitbook -V
CLI version: 2.3.2
Installing GitBook 3.2.3
/root/.nvm/versions/node/v12.22.1/lib/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 /root/.nvm/versions/node/v12.22.1/lib/node_modules/gitbook-cli/node_modules/npm/node_modules/graceful-fs/polyfills.js:287:18
    at FSReqCallback.oncomplete (fs.js:169:5)

使用nvm降低node版本为node v10.24.1

[root]# node -v
v10.24.1
[root]# npm -v
6.14.12
[root]# npm install gitbook-cli -g
/root/.nvm/versions/node/v10.24.1/bin/gitbook -> /root/.nvm/versions/node/v10.24.1/lib/node_modules/gitbook-cli/bin/gitbook.js
+ [email protected]
added 578 packages from 672 contributors in 19.579s
[root]# gitbook -V
CLI version: 2.3.2
GitBook version: 3.2.3

新建文件夹,初始化

[root]# cd /home
[home]# ls
[home]# mkdir docs
[home]# cd docs
[docs]# gitbook init
warn: no summary file in this book 
info: create README.md 
info: create SUMMARY.md 
info: initialization is finished 
[docs]#

启动服务,如下,正常启动,可以在浏览器打开http://你的ip地址:4000查看。

[docs]# 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 1 pages 
info: found 0 asset files 
info: >> generation finished with success in 0.4s ! 

Starting server ...
Serving book on http://localhost:4000
-----------------
nohup gitbook serve &

更换端口启动命令

gitbook serve --lrport 35288 --port 4001
Copyright © OneZos all right reserved,powered by Gitbook本书发布时间: 2021-11-16 19:16:37

results matching ""

    No results matching ""