GitBook CLI
gitbook-cli is a command-line interface tool designed to manage and execute local installations of the open-source GitBook static site generator. It enables users to build, serve, and manage various versions of the GitBook engine (specifically GitBook versions >=2.0.0), storing them in a dedicated directory (defaulting to `~/.gitbook`). The current stable version indicated is 2.3.2. This toolchain facilitated local documentation and book generation, abstracting away direct `gitbook` engine installations. However, the GitBook project has since pivoted to a SaaS-first platform, and this open-source CLI and its associated engine are no longer actively maintained, making it an abandoned project. Its primary differentiator was simplifying local GitBook engine management and execution.
Common errors
-
gitbook: command not found
cause The `gitbook-cli` package was not installed globally or the `npm` global bin path is not in your system's PATH.fixRun `npm install -g gitbook-cli` to install it globally. If the issue persists, ensure your shell's PATH includes `$(npm config get prefix)/bin`. -
Error: GitBook version 1.x.x is not supported by the GitBook CLI. Please upgrade to a version >= 2.0.0.
cause The configured GitBook engine version in `book.json` or specified via `--gitbook` is older than the minimum supported version (2.0.0) by `gitbook-cli`.fixUpdate your `book.json` to specify a GitBook version like `"gitbook": ">=3.0.0"` or explicitly fetch and use a newer version with `gitbook fetch 3.2.3` and then `gitbook build --gitbook=3.2.3`. -
TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments object for strict mode functions at Function.init (fs.js:255:17)
cause This error typically indicates an incompatibility between an older Node.js module (like parts of the GitBook engine) and newer Node.js strict mode execution.fixDowngrade your Node.js version to an older LTS release, such as Node.js 12 or 14, using a Node.js version manager (e.g., `nvm install 14 && nvm use 14`).
Warnings
- breaking The `gitbook-cli` project and the underlying open-source GitBook engine are no longer actively maintained. The official GitBook platform has pivoted to a commercial SaaS model, deprecating the open-source toolchain.
- gotcha gitbook-cli only supports GitBook engine versions `>=2.0.0`. Attempting to use older versions may result in unexpected behavior or errors.
- gotcha Due to the project's abandonment, `gitbook-cli` may have compatibility issues with newer Node.js versions (e.g., Node.js 16+). It was developed during an era of older Node.js LTS releases.
Install
-
npm install gitbook-cli -
yarn add gitbook-cli -
pnpm add gitbook-cli
Quickstart
npm install -g gitbook-cli mkdir my-book cd my-book # Initialize a new GitBook project gitbook init # Build the book gitbook build # Serve the book locally gitbook serve # List installed GitBook versions gitbook ls # Install a specific GitBook version gitbook fetch 3.2.3