Command failed with exit code 127: CI= npm run build

Hi All,

I’m having an issue with deploying the website I’m working on. I believe I have all the right settings to deploy such as:

Base Directory: client
Build command is: CI= npm run build
Publish Directory: client/build

With all this I still get error “Command failed with exit code 127: CI= npm run build”

I have even tried with “CI= ’ ’ npm run build”

below is the log:

3:24:50 PM: Build ready to start
3:25:03 PM: build-image version: d7b3dbfb0846505993c9a131894d1858074c90b4 (focal)
3:25:03 PM: build-image tag: v4.10.1
3:25:03 PM: buildbot version: f45292fab0b32cea549baa8489f553abb9d888be
3:25:03 PM: Fetching cached dependencies
3:25:03 PM: Starting to download cache of 142.1MB
3:25:05 PM: Finished downloading cache in 1.345352294s
3:25:05 PM: Starting to extract cache
3:25:05 PM: Finished extracting cache in 568.29444ms
3:25:05 PM: Finished fetching cache in 1.975465343s
3:25:05 PM: Starting to prepare the repo for build
3:25:05 PM: Preparing Git Reference refs/heads/main
3:25:06 PM: Parsing package.json dependencies
3:25:06 PM: Different publish path detected, going to use the one specified in the Netlify configuration file: ‘client/build’ versus ‘build’ in the Netlify UI
3:25:07 PM: Starting build script
3:25:07 PM: Installing dependencies
3:25:07 PM: Python version set to 2.7
3:25:07 PM: Started restoring cached node version
3:25:08 PM: Finished restoring cached node version
3:25:08 PM: v16.17.0 is already installed.
3:25:08 PM: Now using node v16.17.0 (npm v8.15.0)
3:25:08 PM: Started restoring cached build plugins
3:25:08 PM: Finished restoring cached build plugins
3:25:08 PM: Attempting ruby version 2.7.2, read from environment
3:25:09 PM: Using ruby version 2.7.2
3:25:09 PM: Using PHP version 8.0
3:25:10 PM: npm workspaces detected
3:25:10 PM: Started restoring cached go cache
3:25:10 PM: Finished restoring cached go cache
3:25:10 PM: Installing Go version 1.17 (requested 1.17)
3:25:14 PM: unset GOOS;
3:25:14 PM: unset GOARCH;
3:25:14 PM: export GOROOT=‘/opt/buildhome/.gimme/versions/go1.17.linux.amd64’;
3:25:14 PM: export PATH=“/opt/buildhome/.gimme/versions/go1.17.linux.amd64/bin:${PATH}”;
3:25:14 PM: go version >&2;
3:25:14 PM: export GIMME_ENV=“/opt/buildhome/.gimme/env/go1.17.linux.amd64.env”
3:25:14 PM: go version go1.17 linux/amd64
3:25:14 PM: Installing missing commands
3:25:14 PM: Verify run directory
3:25:15 PM: ​
3:25:15 PM: ────────────────────────────────────────────────────────────────
3:25:15 PM: Netlify Build
3:25:15 PM: ────────────────────────────────────────────────────────────────
3:25:15 PM: ​
3:25:15 PM: ❯ Version
3:25:15 PM: @netlify/build 27.15.7
3:25:15 PM: ​
3:25:15 PM: ❯ Flags
3:25:15 PM: baseRelDir: true
3:25:15 PM: buildId: 6307cc8241fa8b0099c8af3a
3:25:15 PM: deployId: 6307cc8241fa8b0099c8af3c
3:25:15 PM: ​
3:25:15 PM: ❯ Current directory
3:25:15 PM: /opt/build/repo/client
3:25:15 PM: ​
3:25:15 PM: ❯ Config file
3:25:15 PM: No config file was defined: using default values.
3:25:15 PM: ​
3:25:15 PM: ❯ Context
3:25:15 PM: production
3:25:15 PM: ​
3:25:15 PM: ────────────────────────────────────────────────────────────────
3:25:15 PM: 1. Build command from Netlify app
3:25:15 PM: ────────────────────────────────────────────────────────────────
3:25:15 PM: ​
3:25:15 PM: $ CI= npm run build
3:25:16 PM: > v39-geckos-team-05@0.1.0 build
3:25:16 PM: > react-scripts build
3:25:16 PM: /tmp/build-b9780485.sh: 1: react-scripts: not found
3:25:16 PM: ​
3:25:16 PM: ────────────────────────────────────────────────────────────────
3:25:16 PM: “build.command” failed
3:25:16 PM: ────────────────────────────────────────────────────────────────
3:25:16 PM: ​
3:25:16 PM: Error message
3:25:16 PM: Command failed with exit code 127: CI= npm run build (Search results for '"non-zero exit code: 127"' - Netlify Support Forums)
3:25:16 PM: ​
3:25:16 PM: Error location
3:25:16 PM: In Build command from Netlify app:
3:25:16 PM: CI= npm run build
3:25:16 PM: ​
3:25:16 PM: Resolved config
3:25:16 PM: build:
3:25:16 PM: base: /opt/build/repo/client
3:25:16 PM: command: CI= npm run build
3:25:16 PM: commandOrigin: ui
3:25:16 PM: publish: /opt/build/repo/client/build
3:25:16 PM: publishOrigin: ui
3:25:16 PM: Caching artifacts
3:25:16 PM: Started saving build plugins
3:25:16 PM: Finished saving build plugins
3:25:16 PM: Started saving pip cache
3:25:16 PM: Finished saving pip cache
3:25:16 PM: Started saving emacs cask dependencies
3:25:16 PM: Finished saving emacs cask dependencies
3:25:16 PM: Started saving maven dependencies
3:25:16 PM: Finished saving maven dependencies
3:25:16 PM: Started saving boot dependencies
3:25:16 PM: Finished saving boot dependencies
3:25:16 PM: Started saving rust rustup cache
3:25:16 PM: Finished saving rust rustup cache
3:25:16 PM: Started saving go dependencies
3:25:16 PM: Finished saving go dependencies
3:25:16 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
3:25:16 PM: Creating deploy upload records
3:25:16 PM: Failing build: Failed to build site
3:25:16 PM: Failed during stage ‘building site’: Build script returned non-zero exit code: 2 (Search results for '"non-zero exit code: 2"' - Netlify Support Forums)
3:25:16 PM: Finished processing build request in 13.439567323s

Hey there, @cruzma :wave:

Thanks for reaching out. Does your site build locally? Additionally, can you share your URL as well as a screen shot of your build settings? Thanks.

1 Like

Thanks for responding Hillary! yes my site does build locally

my site is: https://dancing-begonia-19fd96.netlify.app/

Build settings:

Based on this @cruzma it appears the react-scripts dependency is not installed. It is in the package.json? It the package.json in the client directory?

the react-scripts dependency is installed in package.json which is also in my client directory

Hi @cruzma,

Thanks for confirming that. Can you try the following build settings:

Build command: cd client && npm run build

We also found this related thread with a solution indicated for the same problem you are encountering here.

Let me know if either of these get you unblocked :slight_smile:

Hi Yujohn,

Thanks for responding! your tip helped!

cd client && npm run build didn’t work for me, but it did give me the idea to try npm install && CI= npm run build which worked.

thanks everyone for your help

2 Likes

Thanks for coming back and letting us know! Glad everything is working now. Happy building :rocket: