1. 程式人生 > >Ubuntu14.04安裝Gitbook及常用問題解決

Ubuntu14.04安裝Gitbook及常用問題解決

一、安裝Gitbook步驟

1、更新ubuntu軟體源

sudo apt-get update
sudo apt-get install -y python-software-properties software-properties-common
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update

2、安裝nodejs

sudo apt-get install nodejs
sudo apt install nodejs-legacy
sudo apt install npm  #npm是nodejs的包管理工具

3、更新npm的包映象源,方便快速下載

sudo npm config set registry https://registry.npm.taobao.org
sudo npm config list

4、全域性安裝n管理器(用於管理nodejs版本)

sudo npm install n -g

5、安裝最新的nodejs(stable版本)

sudo n stable
sudo node -v

6、安裝gitbook

npm install gitbook -g

二、報錯處理

1、安裝時報錯提示

[email protected]
:/home/jk/workspace/wicc/WaykiChain_deply# npm install -g gitbook-cli npm http GET https://registry.npmjs.org/gitbook-cli npm ERR! Error: CERT_UNTRUSTED npm ERR! at SecurePair.<anonymous> (tls.js:1370:32) npm ERR! at SecurePair.EventEmitter.emit (events.js:92:17) npm ERR! at SecurePair.maybeInitFinished (
tls.js:982:10) npm ERR! at CleartextStream.read [as _read] (tls.js:469:13) npm ERR! at CleartextStream.Readable.read (_stream_readable.js:320:10) npm ERR! at EncryptedStream.write [as _write] (tls.js:366:25) npm ERR! at doWrite (_stream_writable.js:223:10) npm ERR! at writeOrBuffer (_stream_writable.js:213:5) npm ERR! at EncryptedStream.Writable.write (_stream_writable.js:180:11) npm ERR! at write (_stream_readable.js:583:24) npm ERR! If you need help, you may report this log at: npm ERR! <http://github.com/isaacs/npm/issues> npm ERR! or email it to: npm ERR! <[email protected]> npm ERR! System Linux 4.4.0-31-generic npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "install" "gitbook-cli" "-g" npm ERR! cwd /home/jk/workspace/wicc/WaykiChain_deply npm ERR! node -v v0.10.25 npm ERR! npm -v 1.3.10 npm ERR! npm ERR! Additional logging details can be found in: npm ERR! /home/jk/workspace/wicc/WaykiChain_deply/npm-debug.log npm ERR! not ok code 0

2、處理過程

經過仔細排查和google,原來是ssl 的問題

[email protected]:/home/jk/workspace/wicc/WaykiChain_deply# npm config set strict-ssl false

3、繼續安裝

[email protected]:/home/jk/workspace/wicc/WaykiChain_deply# npm install -g gitbook-cli
...
npm http 304 https://registry.npmjs.org/graceful-fs
npm WARN engine [email protected]: wanted: {"node":">= 4.0.0"} (current: {"node":"v0.10.25","npm":"1.3.10"})
npm WARN package.json [email protected] No README data
npm WARN package.json [email protected] No README data
npm http 200 https://registry.npmjs.org/npm
npm http GET https://registry.npmjs.org/npm/-/npm-2.15.12.tgz
npm http 200 https://registry.npmjs.org/npm/-/npm-2.15.12.tgz
/usr/local/bin/gitbook -> /usr/local/lib/node_modules/gitbook-cli/bin/gitbook.js
[email protected] /usr/local/lib/node_modules/gitbook-cli
├── [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]:/home/jk/workspace/wicc/WaykiChain_deply# 

4、安裝完成

[email protected]:/home/jk/workspace/wicc/WaykiChain_deply# gitbook -h

  Usage: gitbook [options] [command]


  Options:

    -v, --gitbook [version]  specify GitBook version to use
    -d, --debug              enable verbose error
    -V, --version            Display running versions of gitbook and gitbook-cli
    -h, --help               output usage information


  Commands:

    ls                        List versions installed locally
    current                   Display currently activated version
    ls-remote                 List remote versions available for install
    fetch [version]           Download and install a <version>
    alias [folder] [version]  Set an alias named <version> pointing to <folder>
    uninstall [version]       Uninstall a version
    update [tag]              Update to the latest version of GitBook
    help                      List commands for GitBook
    *                         run a command with a specific gitbook version
[email protected]:/home/jk/workspace/wicc/WaykiChain_deply# gitbook --version
CLI version: 2.3.2
Installing GitBook 3.2.3
[email protected] ../../../../../tmp/tmp-42694AZovNK4FYB1G/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] (range[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
[email protected]:/home/jk/workspace/wicc/WaykiChain_deply#