UbuntuにおけるNode. jsとnpm
GitBookはNode.
Node.
- ※3
- ちなみにNode.
jsの4. xはLTSとなり, 2015年のから2年半サポートされるようです。よって4. 2.xが公式リポジトリに存在するUbuntu 16. 04 LTSであれば, リポジトリからパッケージをインストールするだけで良いかもしれません。
Node.
ドキュメントの手順に従えば,
$ curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash - $ sudo apt-get install -y nodejs
ここでダウンロードしている
- ※4
- むしろこの手順は不安を感じる方が普通だと思います。
$ curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key \ | sudo apt-key add - $ echo 'deb https://deb.nodesource.com/node_4.x trusty main' \ | sudo tee -a /etc/apt/sources.list.d/nodesource.list $ echo 'deb-src https://deb.nodesource.com/node_4.x trusty main' \ | sudo tee -a /etc/apt/sources.list.d/nodesource.list $ sudo apt-get update $ sudo apt-get install nodejs $ node -v v4.2.6
Ubuntu 14.
Node.
update-alternatives --quiet --install /usr/bin/node node \
/usr/bin/nodejs 50 \
--slave /usr/share/man/man1/node.1.gz node.1.gz \
/usr/share/man/man1/nodejs.1.gz
このため
Node.
$ npm -v 2.14.12
npmはnpmコマンドで更新できます。ただし,
$ sudo npm install npm -g /usr/bin/npm -> /usr/lib/node_modules/npm/bin/npm-cli.js npm@3.5.3 /usr/lib/node_modules/npm $ npm -v 3.5.3
グローバルオプション
GitBookのインストールと最初のテスト
GitBookはnpmコマンドでインストールします。これもグローバルオプション付きでインストールしておいたほうが,
$ sudo npm install gitbook-cli -g $ gitbook --version 1.0.1 $ gitbook install
ちなみにインストールしているのはコマンドのフロントエンドである
では,
$ mkdir firstBook && cd $_ $ gitbook init info: init book at /home/ubuntu/firstBook info: detect structure from SUMMARY (if it exists) info: create SUMMARY.md info: create README.md info: initialization is finished Done, without error $ ls README.md SUMMARY.md
このディレクトリはまだGitリポジトリではありませんので,
$ curl -L https://raw.githubusercontent.com/github/gitignore/master/GitBook.gitignore -o .gitignore $ git init Initialized empty Git repository in /home/ubuntu/firstBook/.git/ $ git add . $ git commit -m "Initial commit" [master (root-commit) 96da69a] Initial commit 3 files changed, 18 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 SUMMARY.md
今回はこのまま変更せずにHTMLを生成してみます。
$ gitbook build info: loading book configuration....OK info: load plugin gitbook-plugin-highlight ....OK info: load plugin gitbook-plugin-search ....OK info: load plugin gitbook-plugin-sharing ....OK info: load plugin gitbook-plugin-fontsettings ....OK info: >> 4 plugins loaded info: start generation with website generator info: clean website generatorOK info: generation is finished Done, without error
生成された
GitBookサービスのように,
$ gitbook serve Live reload server started on port: 35729 Press CTRL+C to quit ... (中略) Starting server ... Serving book on http://localhost:4000
この状態でドキュメントのソースを変更すると,