gitbook 运行
报错1:
gitbook serve 执行报错
(node:74404) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 error listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
好像没啥影响 ,忽略就行
报错2:
安装插件lightbox时报错
info: installing plugin “lightbox”
/root/.gitbook/versions/3.2.3/node_modules/npm/node_modules/aproba/index.js:25
if (args[ii] == null) throw missingRequiredArg(ii)
解决方法: 采用npm 安装
npm install gitbook-plugin-lightbox
报错3
gitbook 插件ga加载失败
info: loading plugin “ga”… ERROR
Error: GitBook doesn’t satisfy the requirements of this plugin: >=4.0.0-alpha.0
ga插件是基于gitbook 4.0.0以上的,而系统安装的是3.2.3,
解决方法:升级gitbook
报错4
Error: ENOENT: no such file or directory, stat 'C:\Users\dell\Desktop\code\kubernetes-handbook_book\gitbook\gitbook-plugin-fontsettings\fontsettings.js
解决办法
参考:https://www.jianshu.com/p/f94c0a691ade
用户目录下找到以下文件。
.gitbook\versions\3.2.3\lib\output\website\copyPluginAssets.js 将confirm: true全部替换为false
解决
继续报错:
error: error while generating page "concepts/pod.md":
Template render error: (/usr/share/nginx/html/kubernetes-handbook/concepts/pod.md) [Line 109, Column 187]
unexpected token: .
文件中目标行存在{{}}
符号,使用用{% raw %} this will {{ not be processed }} {% endraw %}
,或手动添加转义或尝试使用高版本gitbook
gitbook build --gitbook=4.0.0-alpha.6
结果还是报错:
C:\Users\dell\AppData\Roaming\npm\node_modules\gitbook-cli\node_modules\npm\node_modules\graceful-fs\polyfills.js:287
if (cb) cb.apply(this, arguments)
^
TypeError: cb.apply is not a function
at C:\Users\dell\AppData\Roaming\npm\node_modules\gitbook-cli\node_modules\npm\node_modules\graceful-fs\polyfills.js:287:18
at FSReqCallback.oncomplete (node:fs:199:5)
使用gitbook安装gitbook-cli时出现gitbook-cli/node_modules/npm/node_modules/graceful-fs/polyfills.js:287 cb.apply is not a function 报错时,是因为最新NodeJS的graceful-fs模块与gitbook-cli不兼容导致的,只需将graceful-fs的版本降到4.2.0即可。
cd /usr/local/lib/node_modules/gitbook-cli/node_modules/npm/node_modules/
npm install graceful-fs@4.2.0 --save
# 或者
直接替换/usr/local/lib/node_modules/gitbook-cli/node_modules/npm/node_modules/graceful-fs/polyfills.js的内容为https://raw.githubusercontent.com/isaacs/node-graceful-fs/168bdb8f0bb3174e8499d4bc5878deead4172c39/polyfills.js里的
参考:https://stackoverflow.com/questions/64211386/gitbook-cli-install-error-typeerror-cb-apply-is-not-a-function-inside-graceful
升级node版本为:10.21.0
报错:
error: error while generating page “README.md”:
TypeError: serialize is not a function
原因:node版本与gitbook 版本不一致,尝试切换gitbook版本,或者node版本
总结: gitbook 在windows环境下各种报错,很难解决,最后重新拉取了最新分支的git资源,git serve运行成功在Linux环境下,安装node 10.21.0版本运行成功( 下载地址 )