gitbook官网:
https://www.gitbook.com/
windows下安装gitbook
安装Node.js
cmd检查是否安装成功
>node -v
v8.11.4
上面的命令只会在你安装node.js的目录下运行才会有效,想要在其他目录下运行也能生效的话,就只能配置环境变量了。
个人建议:最好还是配置一下环境变量。
安装GitBook
使用下面的命令安装GitBook:
cmd下使用
npm install gitbook-cli -g
安装成功,可以使用下面的命令来检验是否安装成功:
E:\gitbook_work>gitbook -V
CLI version: 2.3.2
GitBook version: 3.2.3
gitbook 初始化
E:\gitbook_work>gitbook init
warn: no summary file in this book
info: create README.md
info: create SUMMARY.md
info: initialization is finished
然后在当前的目录下可以看到自动创建了两个.md文件
然后我们输入如下命令:
E:\gitbook_work\demo>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
Error: ENOENT: no such file or directory, stat 'E:\gitbook_work\demo\_book\gitbook\gitbook-plugin-fontsettings\fontsettings.js'
上面说明出现了一个错误的地方:
我们可以修改如下目录的文件:
C:\Users\Administrator.gitbook\versions\3.2.3\lib\output\website\copyPluginAssets.js
在106行中
return fs.copyDir(
assetsFolder,
assetOutputFolder,
{
deleteFirst: false,
overwrite: true,
confirm: true
}
);
修改成:
return fs.copyDir(
assetsFolder,
assetOutputFolder,
{
deleteFirst: false,
overwrite: true,
confirm: false
}
);
解释:C:\Users\Administrator.gitbook\versions\版本号\lib\output\website
然后再运行:
E:\gitbook_work\demo>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 1.7s !
Starting server ...
Serving book on http://localhost:4000
上面就说明运行正常了。
最后可以在浏览器中输入如下命令查看一下:
http://localhost:4000
网友评论