安装参考:Mac GitBook安装和使用
npm -v
node -v
sudo npm install -g gitbook-cli
npm install -g gitbook-cli
是安装不成功的gitbook -v
You need to install "gitbook-cli" to have access to the gitbook command anywhere on your system.
If you've installed this package globally, you need to uninstall it.
>> Run "npm uninstall -g gitbook" then "npm install -g gitbook-cli"
使用参考:GitBook 简明教程
gitbook init
命令初始化书籍目录
README.md
和 SUMMARY.md
两个必须文件README.md
是对书籍的简单介绍SUMMARY.md
是书籍的目录结构gitbook serve
编译和预览书籍
_book
,然后可以访问本地网站http://localhost:4000
来访问书籍http://localhost:4000
,可以随时预览网站效果gitbook serve
,会报错:Error: listen EADDRINUSE: address already in use :::35729
解决方案:(参考:mac关闭指定端口)
gitbook serve
,获取服务的端口号:
Live reload server started on port: 35729
lsof -i:35729
,查看端口的进程信息:
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
node 2771 dd01 23u IPv6 0x7953faeb24d2c63d 0t0 TCP *:35729 (LISTEN)
kill -9 2771
,可以关闭这个进程