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