"gitbook build" deployment failing

Hi,

Netlify site name: lucid-tereshkova-43348e

I’m trying to deploy gitbook based app. I was following this guide:

Here are my build configs:

When I’m trying to deploy, it’s failing.

Link to logs:
https://app.netlify.com/sites/lucid-tereshkova-43348e/deploys/60aa287cba4d9af9b82d150c

Full logs:

12:03:40 PM: Build ready to start
12:03:42 PM: build-image version: 0582042f4fc261adc7bd8333f34884959c577302
12:03:42 PM: build-image tag: v3.7.6
12:03:42 PM: buildbot version: 96f6c6faf398b8f2b7e39c2c3c6a03ac4592e535
12:03:42 PM: Fetching cached dependencies
12:03:42 PM: Failed to fetch cache, continuing with build
12:03:42 PM: Starting to prepare the repo for build
12:03:42 PM: No cached dependencies found. Cloning fresh repo
12:03:42 PM: git clone https://github.com/chettam/compet-book
12:03:43 PM: Preparing Git Reference refs/heads/main
12:03:43 PM: Parsing package.json dependencies
12:03:44 PM: Different build dir detected, going to use the one specified in the Netlify configuration file: '' versus '/' in the Netlify UI
12:03:44 PM: Different publish path detected, going to use the one specified in the Netlify configuration file: '_book' versus '_book/' in the Netlify UI
12:03:44 PM: Starting build script
12:03:45 PM: Installing dependencies
12:03:45 PM: Python version set to 2.7
12:03:46 PM: v12.18.0 is already installed.
12:03:46 PM: Now using node v12.18.0 (npm v6.14.4)
12:03:46 PM: Started restoring cached build plugins
12:03:46 PM: Finished restoring cached build plugins
12:03:46 PM: Attempting ruby version 2.7.1, read from environment
12:03:47 PM: Using ruby version 2.7.1
12:03:47 PM: Using PHP version 5.6
12:03:47 PM: Started restoring cached go cache
12:03:47 PM: Finished restoring cached go cache
12:03:48 PM: go version go1.14.4 linux/amd64
12:03:48 PM: go version go1.14.4 linux/amd64
12:03:48 PM: Installing missing commands
12:03:48 PM: Verify run directory
12:03:49 PM: ​
12:03:49 PM: ────────────────────────────────────────────────────────────────
12:03:49 PM:   Netlify Build                                                 
12:03:49 PM: ────────────────────────────────────────────────────────────────
12:03:49 PM: ​
12:03:49 PM: ❯ Version
12:03:49 PM:   @netlify/build 11.18.0
12:03:49 PM: ​
12:03:49 PM: ❯ Flags
12:03:49 PM:   deployId: 60aa287cba4d9af9b82d150c
12:03:49 PM: ​
12:03:49 PM: ❯ Current directory
12:03:49 PM:   /opt/build/repo
12:03:49 PM: ​
12:03:49 PM: ❯ Config file
12:03:49 PM:   No config file was defined: using default values.
12:03:49 PM: ​
12:03:49 PM: ❯ Context
12:03:49 PM:   production
12:03:49 PM: ​
12:03:49 PM: ────────────────────────────────────────────────────────────────
12:03:49 PM:   1. Build command from Netlify app                             
12:03:49 PM: ────────────────────────────────────────────────────────────────
12:03:49 PM: ​
12:03:49 PM: $ gitbook build
12:03:49 PM: bash: gitbook: command not found
12:03:49 PM: ​
12:03:49 PM: ────────────────────────────────────────────────────────────────
12:03:49 PM:   "build.command" failed                                        
12:03:49 PM: ────────────────────────────────────────────────────────────────
12:03:49 PM: ​
12:03:49 PM:   Error message
12:03:49 PM:   Command failed with exit code 127: gitbook build
12:03:49 PM: ​
12:03:49 PM:   Error location
12:03:49 PM:   In Build command from Netlify app:
12:03:49 PM:   gitbook build
12:03:49 PM: ​
12:03:49 PM:   Resolved config
12:03:49 PM:   build:
12:03:49 PM:     base: /opt/build/repo
12:03:49 PM:     command: gitbook build
12:03:49 PM:     commandOrigin: ui
12:03:49 PM:     publish: /opt/build/repo/_book
12:03:49 PM: Caching artifacts
12:03:49 PM: Started saving build plugins
12:03:49 PM: Finished saving build plugins
12:03:49 PM: Started saving pip cache
12:03:49 PM: Finished saving pip cache
12:03:49 PM: Started saving emacs cask dependencies
12:03:50 PM: Finished saving emacs cask dependencies
12:03:50 PM: Started saving maven dependencies
12:03:50 PM: Finished saving maven dependencies
12:03:50 PM: Started saving boot dependencies
12:03:50 PM: Finished saving boot dependencies
12:03:50 PM: Started saving rust rustup cache
12:03:50 PM: Finished saving rust rustup cache
12:03:50 PM: Started saving go dependencies
12:03:50 PM: Finished saving go dependencies
12:03:52 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
12:03:52 PM: Creating deploy upload records
12:03:52 PM: Failing build: Failed to build site
12:03:52 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2
12:03:52 PM: Finished processing build request in 10.275192322s

Firstly I thought it’s possibly because of missing _book directory, so I created it but it’s still failing.

There’s no package.json in your repo which means when published on Netlify, your repo is missing gitbook and gitbook-cli dependencies because of which the command does not exist.

1 Like

Makes sense! Thank you!