Skip to content
This repository was archived by the owner on Sep 17, 2026. It is now read-only.

Installing Gitbook

Daniel Tolbert edited this page Mar 15, 2018 · 4 revisions

Getting GitBook installed and ready-to-go should only take a few minutes.

Local Installation

Requirements

Installing GitBook is easy and straightforward. Your system just needs to meet these two requirements:

  • NodeJS (v4.0.0+)
  • Windows, Linux, Unix, or Mac OS X

Install with NPM

The best way to install GitBook is via NPM. At the terminal prompt, simply run the following command to install GitBook:

$ npm install gitbook-cli -g

gitbook-cli is an utility to install and use multiple versions of GitBook on the same system. It will automatically install the required version of GitBook to build a book.

Preview and Build the Book

Once the CLI is installed, clone the main branch for the documentation site run the commands:

Install all plugins
$ gitbook install
Serve the documentation
$ gitbook serve
Or build the static website using
$ gitbook build

Using make

The Bandwidth docs also include a helpful makefile that bundles up various commands to streamline deployments.

default: compile

gitbook_install:
  gitbook install

gitbook_build:
  gitbook build

gitbook_serve:
  gitbook serve

compile: gitbook_install gitbook_build

serve: gitbook_install gitbook_serve

You can invoke these commands by calling make (default is to install the plugins and then build the book).

Helpful alaises

Developing the docs locally I have found a few of the plugins (like toggle-chapters) don't play friendly with the auto-refresh with the default serve. Further, some of the docs take about 90seconds to build which can prove to be annoying when making rapid changes

alias gbs="gitbook serve --no-watch --no-live"
alias gbc="rm -rf _book && rm -rf node_modules && gitbook install"
alias gbb="gitbook build"
Command Behavior
gbs Serves the gitbook on localhost:4000 but doesn't auto reload on detecting file changes
gbc Essentially gitbook clean It removes all the generated files from install and build and re-installs all plugins. Helpful when developing new plugins and need to blow away old install files
gbb Runs the gitbook build command. I occassionally use this with http-server watching the ./_book directory to psuedo-get live refresh

Clone this wiki locally