Win10下安装gitbook

背景

有时阅读某些文档时,需要安装gitbook,本文记录一下win10安装gitbook的过程

安装nodejs

地址:https://nodejs.org/en/download/,安装完成后查看结果:

安装gitbook-cli

C:\Users\songzeceng>npm install gitbook-cli -g
D:\develop\nodejs\gitbook -> D:\develop\nodejs\node_modules\gitbook-cli\bin\gitbook.js
+ gitbook-cli@2.3.2
added 578 packages from 672 contributors in 95.472s

C:\Users\songzeceng>gitbook -V
CLI version: 2.3.2
Installing GitBook 3.2.3
gitbook@3.2.3 C:\Users\SONGZE~1\AppData\Local\Temp\tmp-59388512m5RhTctnL\node_modules\gitbook
├── escape-string-regexp@1.0.5
├── escape-html@1.0.3
├── destroy@1.0.4
├── ignore@3.1.2
├── bash-color@0.0.4
├── gitbook-plugin-livereload@0.0.1
├── cp@0.2.0
├── nunjucks-do@1.0.0
├── graceful-fs@4.1.4
├── github-slugid@1.0.1
├── q@1.4.1
├── spawn-cmd@0.0.2
├── gitbook-plugin-fontsettings@2.0.0
├── is@3.3.0
├── open@0.0.5
├── direction@0.1.5
├── object-path@0.9.2
├── extend@3.0.2
├── json-schema-defaults@0.1.1
├── gitbook-plugin-search@2.2.1
├── jsonschema@1.1.0
├── crc@3.4.0
├── urijs@1.18.0
├── semver@5.1.0
├── immutable@3.8.2
├── front-matter@2.3.0
├── dom-serializer@0.1.0 (domelementtype@1.1.3, entities@1.1.2)
├── omit-keys@0.1.0 (isobject@0.2.0, array-difference@0.0.1)
├── error@7.0.2 (xtend@4.0.2, string-template@0.2.1)
├── npmi@2.0.1 (semver@4.3.6)
├── tmp@0.0.28 (os-tmpdir@1.0.2)
├── send@0.13.2 (fresh@0.3.0, statuses@1.2.1, range-parser@1.0.3, etag@1.7.0, ms@0.7.1, depd@1.1.2, debug@2.2.0, mime@1.3.4, http-errors@1.3.1, on-finished@2.3.0)
├── mkdirp@0.5.1 (minimist@0.0.8)
├── rmdir@1.2.0 (node.flow@1.2.3)
├── resolve@1.1.7
├── fresh-require@1.0.3 (is-require@0.0.1, shallow-copy@0.0.1, sleuth@0.1.1, astw@1.3.0, through2@0.6.5, escodegen@1.14.3, acorn@0.9.0)
├── cpr@1.1.1 (rimraf@2.4.5)
├── tiny-lr@0.2.1 (parseurl@1.3.3, livereload-js@2.4.0, qs@5.1.0, debug@2.2.0, body-parser@1.14.2, faye-websocket@0.10.0)
├── js-yaml@3.14.1 (esprima@4.0.1, argparse@1.0.10)
├── gitbook-plugin-theme-default@1.0.7
├── gitbook-plugin-lunr@1.2.0 (html-entities@1.2.0, lunr@0.5.12)
├── chokidar@1.5.0 (async-each@1.0.3, path-is-absolute@1.0.1, inherits@2.0.4, glob-parent@2.0.0, is-glob@2.0.1, is-binary-path@1.0.1, anymatch@1.3.2, readdirp@2.2.1)
├── nunjucks@2.5.2 (asap@2.0.6, yargs@3.32.0, chokidar@1.7.0)
├── read-installed@4.0.3 (debuglog@1.0.1, util-extend@1.0.3, slide@1.1.6, readdir-scoped-modules@1.1.0, read-package-json@2.1.2)
├── gitbook-plugin-highlight@2.0.2 (highlight.js@9.2.0)
├── moment@2.13.0
├── gitbook-plugin-sharing@1.0.2 (lodash@3.10.1)
├── i18n-t@1.0.1 (lodash@4.17.21)
├── cheerio@0.20.0 (entities@1.1.2, css-select@1.2.0, htmlparser2@3.8.3, jsdom@7.2.2, lodash@4.17.21)
├── gitbook-asciidoc@1.2.2 (gitbook-html@1.3.3, asciidoctor.js@1.5.5-1, lodash@4.17.21)
├── gitbook-markdown@1.3.2 (kramed-text-renderer@0.2.1, gitbook-html@1.3.3, kramed@0.5.6, lodash@4.17.21)
├── request@2.72.0 (aws-sign2@0.6.0, tunnel-agent@0.4.3, forever-agent@0.6.1, oauth-sign@0.8.2, caseless@0.11.0, is-typedarray@1.0.0, stringstream@0.0.6, aws4@1.11.0, isstream@0.1.2, json-stringify-safe@5.0.1, tough-cookie@2.2.2, qs@6.1.2, node-uuid@1.4.8, combined-stream@1.0.8, mime-types@2.1.31, bl@1.1.2, hawk@3.1.3, har-validator@2.0.6, http-signature@1.1.1, form-data@1.0.1)
├── juice@2.0.0 (deep-extend@0.4.2, slick@1.12.2, batch@0.5.3, cssom@0.3.1, commander@2.9.0, cross-spawn-async@2.2.5, web-resource-inliner@2.0.0)
└── npm@3.9.2
GitBook version: 3.2.3

在第二步安装gitbook时,如果报错TypeError: cb.apply is not a function,如下图所示

则打开错误提示中的文件(比如这里是D:\develop\nodejs\node_modules\gitbook-cli\node_modules\npm\node_modules\graceful-fs\polyfills.js),注释掉其中statFix()函数的调用即可(62~64行)

......

  fs.chmodSync = chmodFixSync(fs.chmodSync)
  fs.fchmodSync = chmodFixSync(fs.fchmodSync)
  fs.lchmodSync = chmodFixSync(fs.lchmodSync)

//  fs.stat = statFix(fs.stat)
//  fs.fstat = statFix(fs.fstat)
//  fs.lstat = statFix(fs.lstat)

  fs.statSync = statFixSync(fs.statSync)
  fs.fstatSync = statFixSync(fs.fstatSync)
  fs.lstatSync = statFixSync(fs.lstatSync)

......

而后再运行gitbook -V就可以正常安装了,安装完后可以查看一下版本

C:\Users\songzeceng>gitbook -V
CLI version: 2.3.2
GitBook version: 3.2.3

测试

以文档https://github.com/kendryte/kendryte-doc-datasheet为例,按照首页的说明,先gitclone源码,再进入zh-Hans目录,先后运行gitbook install和gitbook serve

D:\lab\aCoralExperiment\OS大赛2021>cd kendryte-doc-datasheet\zh-Hans

D:\lab\aCoralExperiment\OS大赛2021\kendryte-doc-datasheet\zh-Hans>gitbook install
info: installing 8 plugins using npm@3.9.2
info:
info: installing plugin "prism"
info: install plugin "prism" (*) from NPM with version 2.4.0
D:\lab\aCoralExperiment\OS大赛2021\kendryte-doc-datasheet\zh-Hans
`-- gitbook-plugin-prism@2.4.0
  +-- cheerio@0.22.0
  | +-- css-select@1.2.0
  | | +-- boolbase@1.0.0
  | | +-- css-what@2.1.3
  | | +-- domutils@1.5.1
  | | `-- nth-check@1.0.2
  | +-- dom-serializer@0.1.1
  | | `-- domelementtype@1.3.1
  | +-- entities@1.1.2
  | +-- htmlparser2@3.10.1
  | | +-- domhandler@2.4.2
  | | +-- inherits@2.0.4
  | | `-- readable-stream@3.6.0
  | |   +-- string_decoder@1.3.0
  | |   | `-- safe-buffer@5.2.1
  | |   `-- util-deprecate@1.0.2
  | +-- lodash.assignin@4.2.0
  | +-- lodash.bind@4.2.1
  | +-- lodash.defaults@4.2.0
  | +-- lodash.filter@4.6.0
  | +-- lodash.flatten@4.4.0
  | +-- lodash.foreach@4.5.0
  | +-- lodash.map@4.6.0
  | +-- lodash.merge@4.6.2
  | +-- lodash.pick@4.4.0
  | +-- lodash.reduce@4.6.0
  | +-- lodash.reject@4.6.0
  | `-- lodash.some@4.6.0
  +-- mkdirp@0.5.1
  | `-- minimist@0.0.8
  `-- prismjs@1.23.0
    `-- clipboard@2.0.8
      +-- good-listener@1.2.2
      | `-- delegate@3.2.0
      +-- select@1.1.2
      `-- tiny-emitter@2.1.0

info: >> plugin "prism" installed with success
info:
info: installing plugin "footnote-string-to-number"
runTopLevelLifecycles ->  | |######################################################################################---|
D:\lab\aCoralExperiment\OS大赛2021\kendryte-doc-datasheet\zh-Hans
+-- gitbook-plugin-footnote-string-to-number@0.0.2
`-- gitbook-plugin-prism@2.4.0

info: >> plugin "footnote-string-to-number" installed with success
info:
info: installing plugin "search-pro"
runTopLevelLifecycles ->  / |######################################################################################---|
D:\lab\aCoralExperiment\OS大赛2021\kendryte-doc-datasheet\zh-Hans
+-- gitbook-plugin-footnote-string-to-number@0.0.2
+-- gitbook-plugin-prism@2.4.0
`-- gitbook-plugin-search-pro@2.0.2
  `-- html-entities@1.2.0

info: >> plugin "search-pro" installed with success
info:
info: installing plugin "anchors"
runTopLevelLifecycles ->  - |######################################################################################---|
D:\lab\aCoralExperiment\OS大赛2021\kendryte-doc-datasheet\zh-Hans
+-- gitbook-plugin-anchors@0.7.1
| `-- github-slugid@1.0.1
+-- gitbook-plugin-footnote-string-to-number@0.0.2
+-- gitbook-plugin-prism@2.4.0
`-- gitbook-plugin-search-pro@2.0.2

info: >> plugin "anchors" installed with success
info:
info: installing plugin "flow"
runTopLevelLifecycles ->  / |######################################################################################---|
PhantomJS not found on PATH
Downloading https://github.com/Medium/phantomjs/releases/download/v2.1.1/phantomjs-2.1.1-windows.zip
Saving to C:\Users\SONGZE~1\AppData\Local\Temp\phantomjs\phantomjs-2.1.1-windows.zip
Receiving...
  [============================------------] 69%
Received 17767K total.
Extracting zip contents
Removing D:\lab\aCoralExperiment\OS大赛2021\kendryte-doc-datasheet\zh-Hans\node_modules\phantomjs-prebuilt\lib\phantom
Copying extracted folder C:\Users\SONGZE~1\AppData\Local\Temp\phantomjs\phantomjs-2.1.1-windows.zip-extract-1623894974127\phantomjs-2.1.1-windows -> D:\lab\aCoralExperiment\OS大赛2021\kendryte-doc-datasheet\zh-Hans\node_modules\phantomjs-prebuilt\lib\phantom
Writing location.js file
Done. Phantomjs binary available at D:\lab\aCoralExperiment\OS大赛2021\kendryte-doc-datasheet\zh-Hans\node_modules\phantomjs-prebuilt\lib\phantom\bin\phantomjs.exe
D:\lab\aCoralExperiment\OS大赛2021\kendryte-doc-datasheet\zh-Hans
+-- gitbook-plugin-anchors@0.7.1
+-- gitbook-plugin-flow@1.1.7
| +-- phantom@2.1.21
| | +-- linerstream@0.1.4
| | +-- phantomjs-prebuilt@2.1.16
| | | +-- es6-promise@4.2.8
| | | +-- extract-zip@1.7.0
| | | | +-- concat-stream@1.6.2
| | | | | +-- buffer-from@1.1.1
| | | | | +-- readable-stream@2.3.7
| | | | | | +-- core-util-is@1.0.2
| | | | | | +-- isarray@1.0.0
| | | | | | +-- process-nextick-args@2.0.1
| | | | | | +-- safe-buffer@5.1.2
| | | | | | `-- string_decoder@1.1.1
| | | | | `-- typedarray@0.0.6
| | | | +-- debug@2.6.9
| | | | | `-- ms@2.0.0
| | | | +-- mkdirp@0.5.5
| | | | | `-- minimist@1.2.5
| | | | `-- yauzl@2.10.0
| | | |   +-- buffer-crc32@0.2.13
| | | |   `-- fd-slicer@1.1.0
| | | |     `-- pend@1.2.0
| | | +-- fs-extra@1.0.0
| | | | +-- graceful-fs@4.2.6
| | | | +-- jsonfile@2.4.0
| | | | `-- klaw@1.3.1
| | | +-- hasha@2.2.0
| | | | +-- is-stream@1.1.0
| | | | `-- pinkie-promise@2.0.1
| | | |   `-- pinkie@2.0.4
| | | +-- kew@0.7.0
| | | +-- progress@1.1.8
| | | +-- request@2.88.2
| | | | +-- aws-sign2@0.7.0
| | | | +-- aws4@1.11.0
| | | | +-- caseless@0.12.0
| | | | +-- combined-stream@1.0.8
| | | | | `-- delayed-stream@1.0.0
| | | | +-- extend@3.0.2
| | | | +-- forever-agent@0.6.1
| | | | +-- form-data@2.3.3
| | | | | `-- asynckit@0.4.0
| | | | +-- har-validator@5.1.5
| | | | | +-- ajv@6.12.6
| | | | | | +-- fast-deep-equal@3.1.3
| | | | | | +-- fast-json-stable-stringify@2.1.0
| | | | | | +-- json-schema-traverse@0.4.1
| | | | | | `-- uri-js@4.4.1
| | | | | `-- har-schema@2.0.0
| | | | +-- http-signature@1.2.0
| | | | | +-- assert-plus@1.0.0
| | | | | +-- jsprim@1.4.1
| | | | | | +-- extsprintf@1.3.0
| | | | | | +-- json-schema@0.2.3
| | | | | | `-- verror@1.10.0
| | | | | `-- sshpk@1.16.1
| | | | |   +-- asn1@0.2.4
| | | | |   +-- bcrypt-pbkdf@1.0.2
| | | | |   +-- dashdash@1.14.1
| | | | |   +-- ecc-jsbn@0.1.2
| | | | |   +-- getpass@0.1.7
| | | | |   +-- jsbn@0.1.1
| | | | |   +-- safer-buffer@2.1.2
| | | | |   `-- tweetnacl@0.14.5
| | | | +-- is-typedarray@1.0.0
| | | | +-- json-stringify-safe@5.0.1
| | | | +-- mime-types@2.1.31
| | | | | `-- mime-db@1.48.0
| | | | +-- oauth-sign@0.9.0
| | | | +-- performance-now@2.1.0
| | | | +-- qs@6.5.2
| | | | +-- tough-cookie@2.5.0
| | | | | +-- psl@1.8.0
| | | | | `-- punycode@2.1.1
| | | | +-- tunnel-agent@0.6.0
| | | | `-- uuid@3.4.0
| | | +-- request-progress@2.0.1
| | | | `-- throttleit@1.0.0
| | | `-- which@1.3.1
| | |   `-- isexe@2.0.0
| | `-- winston@2.4.5
| |   +-- async@1.0.0
| |   +-- colors@1.0.3
| |   +-- cycle@1.0.3
| |   +-- eyes@0.1.8
| |   +-- isstream@0.1.2
| |   `-- stack-trace@0.0.10
| `-- q@1.5.1
+-- gitbook-plugin-footnote-string-to-number@0.0.2
+-- gitbook-plugin-prism@2.4.0
`-- gitbook-plugin-search-pro@2.0.2


info: >> plugin "flow" installed with success
info:
info: installing plugin "sequence"
runTopLevelLifecycles ->  - |######################################################################################---|
D:\lab\aCoralExperiment\OS大赛2021\kendryte-doc-datasheet\zh-Hans
+-- gitbook-plugin-anchors@0.7.1
+-- gitbook-plugin-flow@1.1.7
+-- gitbook-plugin-footnote-string-to-number@0.0.2
+-- gitbook-plugin-prism@2.4.0
+-- gitbook-plugin-search-pro@2.0.2
`-- gitbook-plugin-sequence@0.1.1

info: >> plugin "sequence" installed with success
info:
info: installing plugin "katex-plus"
runTopLevelLifecycles ->  - |######################################################################################---|
D:\lab\aCoralExperiment\OS大赛2021\kendryte-doc-datasheet\zh-Hans
+-- gitbook-plugin-anchors@0.7.1
+-- gitbook-plugin-flow@1.1.7
+-- gitbook-plugin-footnote-string-to-number@0.0.2
+-- gitbook-plugin-katex-plus@1.1.0
| `-- katex@0.9.0
|   `-- match-at@0.1.1
+-- gitbook-plugin-prism@2.4.0
+-- gitbook-plugin-search-pro@2.0.2
`-- gitbook-plugin-sequence@0.1.1

info: >> plugin "katex-plus" installed with success
info:
info: installing plugin "echarts"
runTopLevelLifecycles ->  | |######################################################################################---|
D:\lab\aCoralExperiment\OS大赛2021\kendryte-doc-datasheet\zh-Hans
+-- gitbook-plugin-anchors@0.7.1
+-- gitbook-plugin-echarts@0.0.17
| +-- crypto@0.0.3
| +-- echarts@4.9.0
| | `-- zrender@4.3.2
| `-- fs-extra@0.30.0
|   +-- path-is-absolute@1.0.1
|   `-- rimraf@2.7.1
|     `-- glob@7.1.7
|       +-- fs.realpath@1.0.0
|       +-- inflight@1.0.6
|       | `-- wrappy@1.0.2
|       +-- minimatch@3.0.4
|       | `-- brace-expansion@1.1.11
|       |   +-- balanced-match@1.0.2
|       |   `-- concat-map@0.0.1
|       `-- once@1.4.0
+-- gitbook-plugin-flow@1.1.7
+-- gitbook-plugin-footnote-string-to-number@0.0.2
+-- gitbook-plugin-katex-plus@1.1.0
+-- gitbook-plugin-prism@2.4.0
+-- gitbook-plugin-search-pro@2.0.2
`-- gitbook-plugin-sequence@0.1.1

info: >> plugin "echarts" installed with success

D:\lab\aCoralExperiment\OS大赛2021\kendryte-doc-datasheet\zh-Hans>gitbook serve
Live reload server started on port: 35729
Press CTRL+C to quit ...

info: 15 plugins are installed
info: 14 explicitly listed
info: loading plugin "prism"... OK
info: loading plugin "footnote-string-to-number"... OK
info: loading plugin "search-pro"... OK
info: loading plugin "anchors"... OK
info: loading plugin "flow"... OK
info: loading plugin "sequence"... OK
info: loading plugin "katex-plus"... OK
info: loading plugin "echarts"... OK
info: loading plugin "livereload"... OK
info: loading plugin "search"... OK
info: loading plugin "lunr"... OK
info: loading plugin "sharing"... OK
info: loading plugin "fontsettings"... OK
info: loading plugin "theme-default"... OK
info: found 6 pages
info: found 7 asset files
warn: "options" property is deprecated, use config.get(key) instead
warn: "options.generator" property is deprecated, use "output.name" instead
warn: "book" property is deprecated, use "this" directly instead
warn: "this.generator" property is deprecated, use "this.output.name" instead
warn: "navigation" property is deprecated
info: >> generation finished with success in 2.5s !

Starting server ...
Serving book on http://localhost:4000

再按照提示访问localhost:4000即可阅读

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值