最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【已解决】基于crifan的gitbook_template恢复gitbook开发环境

gitbook crifan 846浏览 0评论
之前自己写的:
crifan/gitbook_template: 演示如何使用crifan的gitbook的模板去创建自己的gitbook电子书
现在在另外Mac中,尝试恢复环境。
xxx@xxx  ~/dev/crifan/gitbook  git clone https://github.com/crifan/gitbook_template.git
Cloning into 'gitbook_template'...
remote: Enumerating objects: 104, done.
remote: Total 104 (delta 0), reused 0 (delta 0), pack-reused 104
Receiving objects: 100% (104/104), 1.30 MiB | 638.00 KiB/s, done.
Resolving deltas: 100% (28/28), done.
 xxx@xxx  ~/dev/crifan/gitbook  cd gitbook_template
 xxx@xxx  ~/dev/crifan/gitbook/gitbook_template/books   master  cd gitbook_demo
 xxx@xxx  ~/dev/crifan/gitbook/gitbook_template/books/gitbook_demo   master  ll
total 40
-rw-r--r--  1 xxx  CORP\Domain Users    40B  3 17 09:11 Makefile
-rw-r--r--  1 xxx  CORP\Domain Users   1.5K  3 17 09:11 README.md
-rw-r--r--  1 xxx  CORP\Domain Users   233B  3 17 09:11 README_current.json
-rw-r--r--  1 xxx  CORP\Domain Users   3.0K  3 17 09:11 book.json
-rw-r--r--  1 xxx  CORP\Domain Users   456B  3 17 09:11 book_current.json
lrwxr-xr-x  1 xxx  CORP\Domain Users    36B  3 17 09:11 node_modules -> ../../generated/gitbook/node_modules
drwxr-xr-x  9 xxx  CORP\Domain Users   288B  3 17 09:11 src
此处目前还没gitbook命令行工具
 which gitbook
gitbook not found
所以要去安装
mac gitboo cli
chusiang/how-to-build-the-gitbook-with-gitbook-cli: 如何藉由 gitbook-cli 來建置自己的 GitBook。
npm install -g gitbook-cli
log
 npm install -g gitbook-cli
/usr/local/bin/gitbook -> /usr/local/lib/node_modules/gitbook-cli/bin/gitbook.js
+ [email protected]
added 578 packages from 672 contributors in 9.723s


   ╭────────────────────────────────────────────────────────────────╮
   │                                                                │
   │      New minor version of npm available! 6.13.4 → 6.14.2       │
   │   Changelog: https://github.com/npm/cli/releases/tag/v6.14.2   │
   │               Run npm install -g npm to update!                │
   │                                                                │
   ╰────────────────────────────────────────────────────────────────╯
可以找到了:
  which gitbook
/usr/local/bin/gitbook
去看看版本:
  gitbook --version
CLI version: 2.3.2
Installing GitBook 3.2.3
[email protected] ../../../../../../../../var/folders/gt/5868sbcd1jq4rxvryqhy2_1sz8n0s3/T/tmp-11660s4Xx0UYPCvVc/node_modules/gitbook
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected] ([email protected], [email protected])
├── [email protected] ([email protected], [email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
├── [email protected] ([email protected])
├── [email protected]
├── [email protected] ([email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
├── [email protected]
├── [email protected] ([email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected])
├── [email protected] ([email protected])
├── [email protected]
├── [email protected] ([email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected], [email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
└── [email protected]
GitBook version: 3.2.3
然后换个目录,重新打开终端,看看能否找到
 xxx@xxx  ~  which gitbook
/usr/local/bin/gitbook
 xxx@xxx  ~  gitbook --version
CLI version: 2.3.2
GitBook version: 3.2.3
正常了。
再去安装插件
make install
试试
  master  make install
--------------------------------------------------------------------------------
Author  : crifan.com
Version : 20190627
Function: Auto use gitbook to generated files: website/pdf/epub/mobi; upload to remote server; commit to github io repo
        Run 'make help' to see usage
--------------------------------------------------------------------------------
CURRENT_DIR=/Users/xxx/dev/crifan/gitbook/gitbook_template/books/gitbook_demo
BOOK_NAME=gitbook_demo
NOT found gitbook_demo in IGNORE_FILE_CONTENT=
gitbook install
info: installing 17 plugins using [email protected]
info:
info: installing plugin "theme-comscore"
info: install plugin "theme-comscore" (*) from NPM with version 0.0.3
/Users/xxx/dev/crifan/gitbook/gitbook_template/books/gitbook_demo
└── [email protected]

Error: EEXIST: file already exists, mkdir '/Users/xxx/dev/crifan/gitbook/gitbook_template/books/gitbook_demo/node_modules'
make: *** [install] Error 1
对了,是因为此处已有软连接,所以没法新建node_modules。
先把这个ln的软链接删了:
 ✘ xxx@xx  ~/dev/crifan/gitbook/gitbook_template/books/gitbook_demo   master  rm -f node_modules
 xxx@xx  ~/dev/crifan/gitbook/gitbook_template/books/gitbook_demo   master ●  ll
total 40
-rw-r--r--  1 xxx  CORP\Domain Users    40B  3 17 09:11 Makefile
-rw-r--r--  1 xxx  CORP\Domain Users   1.5K  3 17 09:11 README.md
-rw-r--r--  1 xxx  CORP\Domain Users   233B  3 17 09:11 README_current.json
-rw-r--r--  1 xxx  CORP\Domain Users   3.0K  3 17 09:11 book.json
-rw-r--r--  1 xxx  CORP\Domain Users   456B  3 17 09:11 book_current.json
drwxr-xr-x  9 xxx  CORP\Domain Users   288B  3 17 09:11 src
再去安装:
make install
看起来安装很慢,所以:
【未解决】Mac中给gitbook install安装代理或更换源以提高下载速度
  make install
--------------------------------------------------------------------------------
Author  : crifan.com
Version : 20190627
Function: Auto use gitbook to generated files: website/pdf/epub/mobi; upload to remote server; commit to github io repo
        Run 'make help' to see usage
--------------------------------------------------------------------------------
CURRENT_DIR=/Users/xxx/dev/crifan/gitbook/gitbook_template/books/gitbook_demo
BOOK_NAME=gitbook_demo
NOT found gitbook_demo in IGNORE_FILE_CONTENT=
gitbook install
info: installing 17 plugins using [email protected]
info:
info: installing plugin "theme-comscore"
info: install plugin "theme-comscore" (*) from NPM with version 0.0.3
info: >> plugin "theme-comscore" installed with success
info:
info: installing plugin "anchors"
info: install plugin "anchors" (*) from NPM with version 0.7.1
/Users/xxx/dev/crifan/gitbook/gitbook_template/books/gitbook_demo
├─┬ [email protected]
│ ├─┬ [email protected]
│ │ ├─┬ [email protected]
│ │ │ ├── [email protected]
│ │ │ ├── [email protected]
│ │ │ ├── [email protected]
│ │ │ └── [email protected]
│ │ ├─┬ [email protected]
│ │ │ └── [email protected]
│ │ ├── [email protected]
│ │ ├─┬ [email protected]
│ │ │ ├── [email protected]
│ │ │ ├── [email protected]
│ │ │ └─┬ [email protected]
│ │ │   ├─┬ [email protected]
│ │ │   │ └── [email protected]
│ │ │   └── [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ └── [email protected]
│ └── [email protected]
└── [email protected]


info: >> plugin "anchors" installed with success
...
info: >> plugin "callouts" installed with success
info:
info: installing plugin "toolbar-button"
runTopLevelLifecycles → 2 ▌ ╢██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████░░░░░╟
/Users/xxx/dev/crifan/gitbook/gitbook_template/books/gitbook_demo
├── [email protected]
├─┬ [email protected]
│ └─┬ [email protected]
│   └─┬ [email protected]
│     └── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]


info: >> plugin "toolbar-button" installed with success
安装完毕了。
●  ll
total 40
-rw-r--r--   1 xxx  CORP\Domain Users    40B  3 17 09:11 Makefile
-rw-r--r--   1 xxx  CORP\Domain Users   1.5K  3 17 09:11 README.md
-rw-r--r--   1 xxx  CORP\Domain Users   233B  3 17 09:11 README_current.json
-rw-r--r--   1 xxx  CORP\Domain Users   3.0K  3 17 09:11 book.json
-rw-r--r--   1 xxx  CORP\Domain Users   456B  3 17 09:11 book_current.json
drwxr-xr-x  66 xxx  CORP\Domain Users   2.1K  3 17 10:07 node_modules
drwxr-xr-x   9 xxx  CORP\Domain Users   288B  3 17 09:41 src
后续再把node_modules移动到 generated
以及再去make debug看看
  make debug
--------------------------------------------------------------------------------
Author  : crifan.com
Version : 20190627
Function: Auto use gitbook to generated files: website/pdf/epub/mobi; upload to remote server; commit to github io repo
        Run 'make help' to see usage
--------------------------------------------------------------------------------
CURRENT_DIR=/Users/xxx/dev/crifan/gitbook/gitbook_template/books/gitbook_demo
BOOK_NAME=gitbook_demo
NOT found gitbook_demo in IGNORE_FILE_CONTENT=
rm -f book.json
rm -f README.md
Complete load json from /Users/xxx/dev/crifan/gitbook/gitbook_template/books/gitbook_demo/README_current.json
Complete save file /Users/xxx/dev/crifan/gitbook/gitbook_template/books/gitbook_demo/README.md
cp README.md ./src/README.md
cp /Users/xxx/dev/crifan/gitbook/gitbook_template/common/config/common/common_gitignore .gitignore
Complete sync content
rm -rf /Users/xxx/dev/crifan/gitbook/gitbook_template/generated/books/gitbook_demo/debug
mkdir -p /Users/xxx/dev/crifan/gitbook/gitbook_template/generated/books/gitbook_demo/debug
gitbook serve /Users/xxx/dev/crifan/gitbook/gitbook_template/books/gitbook_demo /Users/xxx/dev/crifan/gitbook/gitbook_template/generated/books/gitbook_demo/debug --log debug
Live reload server started on port: 35729
Press CTRL+C to quit ...


debug: readme found at README.md
debug: summary file found at SUMMARY.md
debug: cleanup folder "/Users/xxx/dev/crifan/gitbook/gitbook_template/generated/books/gitbook_demo/debug"
info: 24 plugins are installed
info: 20 explicitly listed
info: loading plugin "anchors"... OK
info: loading plugin "search-plus"... OK
info: loading plugin "disqus"... OK
info: loading plugin "prism"... OK
info: loading plugin "prism-themes"... OK
info: loading plugin "github-buttons"... OK
info: loading plugin "splitter"... OK
info: loading plugin "sharing-plus"... OK
info: loading plugin "tbfed-pagefooter"... OK
info: loading plugin "expandable-chapters-small"... OK
info: loading plugin "ga"... OK
info: loading plugin "donate"... OK
info: loading plugin "sitemap-general"... OK
info: loading plugin "copy-code-button"... OK
info: loading plugin "callouts"... OK
info: loading plugin "toolbar-button"... OK
info: loading plugin "livereload"... OK
info: loading plugin "fontsettings"... OK
info: loading plugin "theme-comscore"... OK
info: loading plugin "theme-default"... OK
info: found 11 pages
info: found 2 asset files
debug: calling hook "config"
debug: calling hook "init"
warn: "options" property is deprecated, use config.get(key) instead
warn: "options.generator" property is deprecated, use "output.name" instead
init!
debug: copy assets from theme /Users/xxx/.gitbook/versions/3.2.3/node_modules/gitbook-plugin-theme-default/_assets/website
debug: copy resources from plugin /Users/xxx/dev/crifan/gitbook/gitbook_template/books/gitbook_demo/node_modules/gitbook-plugin-theme-comscore/book
debug: copy resources from plugin /Users/xxx/.gitbook/versions/3.2.3/node_modules/gitbook-plugin-fontsettings/assets
debug: copy resources from plugin /Users/xxx/.gitbook/versions/3.2.3/node_modules/gitbook-plugin-livereload/book
debug: copy resources from plugin /Users/xxx/dev/crifan/gitbook/gitbook_template/books/gitbook_demo/node_modules/gitbook-plugin-toolbar-button/book
debug: copy resources from plugin /Users/xxx/dev/crifan/gitbook/gitbook_template/books/gitbook_demo/node_modules/gitbook-plugin-callouts/book
debug: copy resources from plugin /Users/xxx/dev/crifan/gitbook/gitbook_template/books/gitbook_demo/node_modules/gitbook-plugin-copy-code-button/book
debug: copy resources from plugin /Users/xxx/dev/crifan/gitbook/gitbook_template/books/gitbook_demo/node_modules/gitbook-plugin-donate/assets
debug: copy resources from plugin /Users/xxx/dev/crifan/gitbook/gitbook_template/books/gitbook_demo/node_modules/gitbook-plugin-ga/book
debug: copy resources from plugin /Users/xxx/dev/crifan/gitbook/gitbook_template/books/gitbook_demo/node_modules/gitbook-plugin-expandable-chapters-small/book
debug: copy resources from plugin /Users/xxx/dev/crifan/gitbook/gitbook_template/books/gitbook_demo/node_modules/gitbook-plugin-tbfed-pagefooter/assets
debug: copy resources from plugin /Users/xxx/dev/crifan/gitbook/gitbook_template/books/gitbook_demo/node_modules/gitbook-plugin-sharing-plus/assets
debug: copy resources from plugin /Users/xxx/dev/crifan/gitbook/gitbook_template/books/gitbook_demo/node_modules/gitbook-plugin-splitter/book
debug: copy resources from plugin /Users/xxx/dev/crifan/gitbook/gitbook_template/books/gitbook_demo/node_modules/gitbook-plugin-github-buttons/lib
debug: copy resources from plugin /Users/xxx/dev/crifan/gitbook/gitbook_template/books/gitbook_demo/node_modules/prism-themes/themes
debug: copy resources from plugin /Users/xxx/dev/crifan/gitbook/gitbook_template/books/gitbook_demo/node_modules/gitbook-plugin-disqus/book
debug: copy resources from plugin /Users/xxx/dev/crifan/gitbook/gitbook_template/books/gitbook_demo/node_modules/gitbook-plugin-search-plus/assets
debug: copy resources from plugin /Users/xxx/dev/crifan/gitbook/gitbook_template/books/gitbook_demo/node_modules/gitbook-plugin-anchors/assets
debug: copy asset "assets/favicon.ico"
debug: copy asset "assets/img/crifan_github_home.png"
debug: generate page "README.md"
debug: calling hook "page:before"
debug: calling hook "page"
debug: index page README.md
debug: generate page "chapter_1/README.md"
debug: calling hook "page:before"
debug: calling hook "page"
debug: index page chapter_1/README.md
debug: generate page "chapter_2/README.md"
debug: calling hook "page:before"
debug: calling hook "page"
debug: index page chapter_2/README.md
debug: generate page "chapter_2/ch2_section_1.md"
debug: calling hook "page:before"
debug: calling hook "page"
debug: index page chapter_2/ch2_section_1.md
debug: generate page "chapter_2/ch2_section_2.md"
debug: calling hook "page:before"
debug: calling hook "page"
debug: index page chapter_2/ch2_section_2.md
debug: generate page "chapter_3/README.md"
debug: calling hook "page:before"
debug: calling hook "page"
debug: index page chapter_3/README.md
debug: generate page "chapter_3/ch3_structure_list.md"
debug: calling hook "page:before"
debug: calling hook "page"
debug: index page chapter_3/ch3_structure_list.md
debug: generate page "chapter_3/ch3_hint_callout.md"
debug: calling hook "page:before"
debug: calling hook "page"
debug: index page chapter_3/ch3_hint_callout.md
debug: generate page "chapter_3/ch3_code_highlight.md"
debug: calling hook "page:before"
debug: calling hook "page"
debug: index page chapter_3/ch3_code_highlight.md
debug: generate page "appendix/README.md"
debug: calling hook "page:before"
debug: calling hook "page"
debug: index page appendix/README.md
debug: generate page "appendix/reference.md"
debug: calling hook "page:before"
debug: calling hook "page"
debug: index page appendix/reference.md
debug: calling hook "finish:before"
debug: calling hook "finish"
debug: write search index
finish!
info: >> generation finished with success in 1.4s !


Starting server ...
Serving book on http://localhost:4000
然后浏览器中打开
http://localhost:4000/
可以看到我们要的gitbook电子书网页了:
至此,本地恢复gitbook的开发环境,就完成了。
剩下的就是写内容了。
不过,顺带还是去把node_modules,移动到公共位置:
 ✘ xxx@xx  ~/dev/crifan/gitbook/gitbook_template/books/gitbook_demo   master ●  ll ../../generated/gitbook
 xxx@xx  ~/dev/crifan/gitbook/gitbook_template/books/gitbook_demo   master ●  mv node_modules ../../generated/gitbook
 xxx@xx  ~/dev/crifan/gitbook/gitbook_template/books/gitbook_demo   master ●  ll
total 40
-rw-r--r--  1 xxx  CORP\Domain Users    40B  3 17 09:11 Makefile
-rw-r--r--  1 xxx  CORP\Domain Users   1.5K  3 19 09:18 README.md
-rw-r--r--  1 xxx  CORP\Domain Users   233B  3 17 09:11 README_current.json
-rw-r--r--  1 xxx  CORP\Domain Users   2.9K  3 19 09:18 book.json
-rw-r--r--  1 xxx  CORP\Domain Users   456B  3 17 09:11 book_current.json
drwxr-xr-x  9 xxx  CORP\Domain Users   288B  3 17 09:41 src
 xxx@xx  ~/dev/crifan/gitbook/gitbook_template/books/gitbook_demo   master ●  ll ../../generated/gitbook
total 0
drwxr-xr-x  66 xxx  CORP\Domain Users   2.1K  3 17 10:07 node_modules
 xxx@xx  ~/dev/crifan/gitbook/gitbook_template/books/gitbook_demo   master ●  ln -s ../../generated/gitbook/node_modules node_modules
 xxx@xx  ~/dev/crifan/gitbook/gitbook_template/books/gitbook_demo   master ●  ll
total 40
-rw-r--r--  1 xxx  CORP\Domain Users    40B  3 17 09:11 Makefile
-rw-r--r--  1 xxx  CORP\Domain Users   1.5K  3 19 09:18 README.md
-rw-r--r--  1 xxx  CORP\Domain Users   233B  3 17 09:11 README_current.json
-rw-r--r--  1 xxx  CORP\Domain Users   2.9K  3 19 09:18 book.json
-rw-r--r--  1 xxx  CORP\Domain Users   456B  3 17 09:11 book_current.json
lrwxr-xr-x  1 xxx  CORP\Domain Users    36B  3 19 09:22 node_modules -> ../../generated/gitbook/node_modules
drwxr-xr-x  9 xxx  CORP\Domain Users   288B  3 17 09:41 src
即可。
【总结】
此处用自己的gitbook_template,恢复gitbook本地开发环境步骤是:
git clone https://github.com/crifan/gitbook_template.git
cd gitbook_template
cd gitbook_demo
rm -f node_modules
安装gitbook命令行工具:
npm install -g gitbook-cli
很慢,等待安装完成即可。
make install
内部会调用
gitbook install
基于此处book.json的配置去安装插件
安装完毕后,本地会多出node_modules文件夹
然后移动到公共位置:
mv node_modules ../../generated/gitbook
ln -s ../../generated/gitbook/node_modules node_modules
即可。
之后即可愉快的:
make debug
去本地调试和编写gitbook了。

转载请注明:在路上 » 【已解决】基于crifan的gitbook_template恢复gitbook开发环境

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
82 queries in 0.164 seconds, using 22.19MB memory