1.安装npm

yum -y install npm

2.配置npm仓

npm config set registry https://mirrors.tencent.com/npm/

3.安装gitbook-cli和gitbook

npm install gitbook-cli -g

npm install gitbook -g

查看是否安装成功:gitbook -V

4.编译book

进入到book工程根目录,执行:gitbook build

5.启动服务gitbook serve

工程目录下执行:gitbook serve ./ --port=80

其中,--port指定端口,默认是4000

6.问题汇总

1.安装gitbook-cli时,报错TypeError: cb.apply is not a function,报错截图如下:



原因:graceful-fs兼容问题

解决办法:进入到报错提示里的目录,我这边是进入到/usr/local/lib/node_modules/gitbook-cli/node_modules/npm/node_modules/graceful-fs/,执行npm install graceful-fs@latest --save,安装最新的graceful-fs

2.执行build时报错,TypeError: Cannot read property 'pipes' of undefined,报错截图如下:



原因:graceful-fs兼容问题

解决办法:同问题1,将版本指定到4.2.0(应该是某些版本有问题而已)npm install graceful-fs@4.2.0 --save

强烈建议:文件名不要有中文,尽量不要用特殊字符,避免踩坑

7.初始化脚本
#!/bin/bash

# 找不到则安装
if ! which gitbook > /dev/null 2>&1; then
echo "start init."
# 安装npm
yum -y install npm
# 配置npm源
npm config set registry https://mirrors.tencent.com/npm/
# 安装gitbook-cli和gitbook
npm install gitbook-cli -g
npm install gitbook -g
# 解决版本兼容
if which gitbook > /dev/null 2>&1; then
# npm依赖包安装路径
node_modules_path=$(npm root -g)
cd $node_modules_path/gitbook-cli/node_modules/npm/node_modules/
npm install graceful-fs@4.2.0 --save
echo "init success."
fi
fi

最新文章

  1. OS X 添加环境变量
  2. Oracle启动的整个过程
  3. libthrift0.9.0解析(五)之TNonblockingServer&THsHaServer
  4. uva 10036 Problem C: Divisibility
  5. 获取CPU序列号
  6. VS2008中Run-Time Check Failure #2 - Stack around the variable 'xxx' was corrupted 错误解决方法
  7. vue系列之动态路由【原创】
  8. Plant(𝐶𝑜𝑑𝑒𝐹𝑜𝑟𝑐𝑒𝑠 − 185𝐴)
  9. hdu4280 Island Transport 最大流
  10. 记关于vue-cli3 本地代理模拟数据的实践
  11. appstore防代充的一些想法
  12. Palindrome Number leetcode java
  13. UIVisualEffectView(高斯模糊效果)
  14. JedisPool无法获得资源问题
  15. Python----初次见面,请多关照!
  16. Android笔记——对系统通话记录的删除操作
  17. mysql 中添加索引的三种方法
  18. SaltStack远程执行shell脚本
  19. Spring---资源访问工具类
  20. 剑指Offer的学习笔记(C#篇)-- 斐波那契数列

热门文章

  1. python多线程参考文章
  2. C# 自定义时间进度条
  3. 攻防世界 reverse elrond32
  4. Java系列教程-Spring 教程目录
  5. Android Studio 之 BaseAdapter 学习笔记
  6. Oment++ 初学者教程 第4节-将其转变为真实网络
  7. AppDomain实现【插件式】开发
  8. javascript是一种什么样的语言
  9. Java8中的默认方法
  10. 【3.0 递归 Recursion 02】