gitbook安裝與使用之windows下搭建gitbook平台
1、安裝C++的環境(安裝vcredist_x64)
2、安裝nodejs,下載地址http://nodejs.cn/download/
3、然后通過cmd調出DOS命令窗口測試下是否安裝完成
輸入命令:node
輸入:console.log("Hello,World!");
4、搭建gitbook平台
輸入命令 npm install gitbook-cli -g
5、初始化gitbook
在CMD窗口中輸入 mkdir mybook
創建文件夾-切換到目錄下.
gitbook init //初始化目錄文件
切換文件夾后在當前文件目錄下的在窗口中輸入如下命令
6、gitbook安裝好之后 gitbook serve
解壓書籍文件,並cd到書籍文件目錄
后就可以輸入http://127.0.0.1:4000/ 訪問了
1、需要安裝node.js。去官網下載對應的版本就可以了https://nodejs.org/en/
2、安裝cnpm,其實安裝npm也可以的。。
npm install cnpm -g --registry=https://registry.npm.taobao.org
3、cnpm install -g gitbook-cli
4、cd 到要查看的文件目錄
5、gitbook serve
6、http://127.0.0.1:4000/ 瀏覽器查看電子書 這個簡單
gitbook踩坑
gitbook serve命令執行反復報以下報錯
Error: Couldn't locate plugins "toggle-chapters, splitter, anchor-navigation-ex, prism, copy-code-button, alerts, theme-comscore", Run 'gitbook install' to install plugins from registry.
Error: ENOENT: no such file or directory, stat 'D:\workspace\core-solution-docs\_book\gitbook\gitbook-plugin-fontsettings\fontsettings.js'
Error: ENOENT: no such file or directory, stat 'D:\workspace\core-solution-docs\_book\gitbook\gitbook-plugin-livereload\plugin.js'
Error: ENOENT: no such file or directory, stat 'D:\workspace\core-solution-docs\_book\gitbook\gitbook-plugin-alerts\plugin.js'
Error: ENOENT: no such file or directory, stat 'D:\workspace\core-solution-docs\_book\gitbook\gitbook-plugin-livereload\plugin.js'
Error: ENOENT: no such file or directory, stat 'D:\workspace\core-solution-docs\_book\gitbook\gitbook-plugin-search\lunr.min.js'
解決方案:
修改用戶目錄的.gitbook\versions\3.2.3\lib\output\website\copyPluginAssets.js文件,把112行的confirm改為false。

{
"title": "python數據結構",
"description": "problem solving ",
"author": "zh",
"language": "zh-hans",
"styles": {
"website": "style.css"
},
"plugins": [
"-lunr",
"-search",
"-livereload",
"-sharing",
"book-summary-scroll-position-saver",
"expandable-chapters",
"search-plus",
"splitter",
"tbfed-pagefooter",
"back-to-top-button",
"yahei",
"katex",
"theme-api",
"theme-comscore"
],
"pluginsConfig": {
"expandable-chapters": {},
"theme-api": { "theme": "light" },
"tbfed-pagefooter": {
"copyright": "© HeDonghai",
"modify_label": "文件修訂時間:",
"modify_format": "YYYY-MM-DD HH:mm:ss"
},
"fontSettings": {
"theme": "white",
"family": "msyh",
"size": 2
}
},
"pdf": {
"toc": true,
"pageNumbers": true,
"fontSize": 18,
"paperSize": "a4",
"margin": {
"right": 30,
"left": 30,
"top": 30,
"bottom": 50
}
}
}