Windows10 gitbook本地搭建(nodejs v10.23.0)

1.下载Nodejs并安装,默认路径即可。(用最新的版本没成功,按照一篇博客里提示的版本nodejs v10.23.0,成功创建gitbook)

https://nodejs.org/download/release/v10.23.0/node-v10.23.0-x64.msi

2.命令行查看一下版本

 如果npm版本不对就安装一下:npm -g install npm@6.14.8

3.安装gitbook-cli:npm install -g gitbook-cli

C:\Users\zhang>npm install -g gitbook-cli
C:\Users\zhang\AppData\Roaming\npm\gitbook -> C:\Users\zhang\AppData\Roaming\npm\node_modules\gitbook-cli\bin\gitbook.js
+ gitbook-cli@2.3.2
added 105 packages from 71 contributors, removed 629 packages and updated 25 packages in 32.979s

4.创建一本gitbook

C:\Users\zhang>d:
D:\>mkdir gitbook
D:\>cd gitbook
D:\gitbook>mkdir firstbook
D:\gitbook>cd firstbook
D:\gitbook\firstbook>gitbook init
Installing GitBook 3.2.3
(node:15092) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 error listeners added. Use emitter.setMaxListeners() to increase limit
(node:15092) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 error listeners added. Use emitter.setMaxListeners() to increase limit
gitbook@3.2.3 C:\Users\ZHANGJ~1\AppData\Local\Temp\tmp-15092fYD26BQCpSWV\node_modules\gitbook
├── escape-string-regexp@1.0.5
├── escape-html@1.0.3
├── destroy@1.0.4
├── chokidar@1.5.0 (async-each@1.0.3, path-is-absolute@1.0.1, inherits@2.0.4, glob-parent@2.0.0, is-glob@2.0.1, is-binary-path@1.0.1, anymatch@1.3.2, readdirp@2.2.1)
└── nunjucks@2.5.2 (asap@2.0.6, yargs@3.32.0, chokidar@1.7.0)
info: create README.md
info: create SUMMARY.md
info: initialization is finished
gitbook init执行成功会产生两个文件,目录:SUMMARY.md,第一篇文章:README.md
# Summary  -- 这个是标题

* [Introduction](README.md) -- 这个是引用README.md,相当于建立一个超级链接,中括号里的是一个提示内容,可自定义。

5.启动server:

D:\gitbook\firstbook>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 2 pages
info: found 0 asset files
info: >> generation finished with success in 0.7s !

Starting server ...
Serving book on http://localhost:4000

6.在浏览器里访问:

 7._book目录可以直接拷贝到nginx目录或者放到github里访问,相当于生成了一个静态站点。

参考:

1.https://blog.csdn.net/weixin_50920579/article/details/123179462

2.https://blog.csdn.net/weixin_50920579/article/details/123161481

3.https://baijiahao.baidu.com/s?id=1721076634433156540&wfr=spider&for=pc

4.https://apioak.com/zh_CN/basic-information/gitbook-local-building.html

posted @ 2022-12-08 17:19  船长博客  阅读(548)  评论(0编辑  收藏  举报
永远相信美好的事情即将发生!