搭建node环境,安装gitbook后着急的运行gitbook build遇到第一个坑:注意关键信息:注意关键信息:
TypeError: cb.apply is not a function at /usr/local/lib/node_modules/gitbook-cli/node_modules/npm/node_modules/graceful-fs/polyfills.js:287:18
解决方法polyfills.js注释掉三个函数(62-64行):
sudo vim /usr/local/lib/node_modules/gitbook-cli/node_modules/npm/node_modules/graceful-fs/polyfills.js
//fs.stat = statFix(fs.stat) //fs.fstat = statFix(fs.fstat) //fs.lstat = statFix(fs.lstat)
第二个坑是运行gitbook init遇到的
TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received an instance of Promise 解决方法:原因未知,对node进行降级:v14.16.1 -> v12.22.1处理后解决
nvm use V12.11.1
第三个坑运行gitbook pdf
InstallRequiredError: "ebook-convert" is not installed.
按照提示,从https://calibre-ebook.com,下载安装符合系统版本软件安装。
例如下载路径为:https://download.calibre-ebook.com/5.16.1/calibre-5.16.1.dmg
配置ebook-convert路径参考:http://caibaojian.com/gitbook/build/ebookconvert.html
删除以前的旧路径用:
sudo rm /usr/local/bin/ebook-convert
增加PATH路径配置,首先打开这个文件:
sudo vim ~/.zshrc
export PATH="/Applications/calibre.app/Contents/MacOS:$PATH"
source ~/.zshrc