"build.command" failed without error log

Hi all,

I’m attempting to deploy my react app but I am getting Failed during stage 'building site': Build script returned non-zero exit code: 2 when I do so. The problem is that it doesn’t seems to log what the failure is (only warnings)

1:39:54 PM: build-image version: d7b3813f01c06610bc1723ff1b22446513ee7941 (focal)
1:39:54 PM: build-image tag: v4.14.3
1:39:54 PM: buildbot version: 4dcf475b8df8e5368becf6538fc83d1d4914f8fc
1:39:54 PM: Fetching cached dependencies
1:39:54 PM: Starting to download cache of 104.0MB
1:39:55 PM: Finished downloading cache in 1.115464309s
1:39:55 PM: Starting to extract cache
1:39:56 PM: Finished extracting cache in 1.102057223s
1:39:56 PM: Finished fetching cache in 2.263175767s
1:39:56 PM: Starting to prepare the repo for build
1:39:57 PM: Preparing Git Reference pull/1/head
1:39:57 PM: Parsing package.json dependencies
1:39:58 PM: Starting build script
1:39:58 PM: Installing dependencies
1:39:58 PM: Python version set to 2.7
1:39:59 PM: Started restoring cached node version
1:39:59 PM: Finished restoring cached node version
1:39:59 PM: v16.18.0 is already installed.
1:40:00 PM: Now using node v16.18.0 (npm v8.19.2)
1:40:00 PM: Enabling node corepack
1:40:00 PM: Started restoring cached build plugins
1:40:00 PM: Finished restoring cached build plugins
1:40:00 PM: Attempting ruby version 2.7.2, read from environment
1:40:00 PM: Using ruby version 2.7.2
1:40:01 PM: Using PHP version 8.0
1:40:01 PM: No npm workspaces detected
1:40:01 PM: Started restoring cached node modules
1:40:01 PM: Finished restoring cached node modules
1:40:01 PM: Installing NPM modules using NPM version 8.19.2
1:40:05 PM: added 140 packages, removed 214 packages, changed 32 packages, and audited 1369 packages in 4s
1:40:05 PM: 213 packages are looking for funding
1:40:05 PM:   run `npm fund` for details
1:40:05 PM: 6 high severity vulnerabilities
1:40:05 PM: To address all issues (including breaking changes), run:
1:40:05 PM:   npm audit fix --force
1:40:05 PM: Run `npm audit` for details.
1:40:05 PM: NPM modules installed
1:40:05 PM: Creating package sha
1:40:05 PM: Started restoring cached go cache
1:40:05 PM: Finished restoring cached go cache
1:40:05 PM: Installing Go version 1.17 (requested 1.17)
1:40:09 PM: unset GOOS;
1:40:09 PM: unset GOARCH;
1:40:09 PM: export GOROOT='/opt/buildhome/.gimme/versions/go1.17.linux.amd64';
1:40:09 PM: export PATH="/opt/buildhome/.gimme/versions/go1.17.linux.amd64/bin:${PATH}";
1:40:09 PM: go version >&2;
1:40:09 PM: export GIMME_ENV="/opt/buildhome/.gimme/env/go1.17.linux.amd64.env"
1:40:09 PM: go version go1.17 linux/amd64
1:40:10 PM: Detected 1 framework(s)
1:40:10 PM: "create-react-app" at version "5.0.1"
1:40:10 PM: Installing missing commands
1:40:10 PM: Verify run directory
1:40:11 PM: ​
1:40:11 PM: ────────────────────────────────────────────────────────────────
1:40:11 PM:   Netlify Build                                                 
1:40:11 PM: ────────────────────────────────────────────────────────────────
1:40:11 PM: ​
1:40:11 PM: ❯ Version
1:40:11 PM:   @netlify/build 28.1.7
1:40:11 PM: ​
1:40:11 PM: ❯ Flags
1:40:11 PM:   baseRelDir: true
1:40:11 PM:   buildId: 63650818c527200008cf7a1c
1:40:11 PM:   deployId: 63650818c527200008cf7a1e
1:40:11 PM: ​
1:40:11 PM: ❯ Current directory
1:40:11 PM:   /opt/build/repo
1:40:11 PM: ​
1:40:11 PM: ❯ Config file
1:40:11 PM:   No config file was defined: using default values.
1:40:11 PM: ​
1:40:11 PM: ❯ Context
1:40:11 PM:   deploy-preview
1:40:11 PM: ​
1:40:11 PM: ────────────────────────────────────────────────────────────────
1:40:11 PM:   1. Build command from Netlify app                             
1:40:11 PM: ────────────────────────────────────────────────────────────────
1:40:11 PM: ​
1:40:11 PM: $ npm run build
1:40:11 PM: > storybook-import-app@0.1.0 build
1:40:11 PM: > react-scripts build
1:40:12 PM: Creating an optimized production build...
1:40:32 PM: 
1:40:32 PM: Treating warnings as errors because process.env.CI = true.
1:40:32 PM: Most CI servers set it automatically.
1:40:32 PM: 
1:40:32 PM: Failed to compile.
1:40:32 PM: 
1:40:32 PM: Warning
1:40:32 PM: (1024:3) autoprefixer: start value has mixed support, consider using flex-start instead
1:40:32 PM: Warning
1:40:32 PM: (14:3) autoprefixer: start value has mixed support, consider using flex-start instead
1:40:32 PM: Warning
1:40:32 PM: (15:3) autoprefixer: start value has mixed support, consider using flex-start instead
1:40:32 PM: Warning
1:40:32 PM: (42:3) autoprefixer: start value has mixed support, consider using flex-start instead
1:40:33 PM: Creating deploy upload records
1:40:32 PM: Warning
1:40:32 PM: (43:3) autoprefixer: start value has mixed support, consider using flex-start instead
1:40:32 PM: ​
1:40:32 PM: ────────────────────────────────────────────────────────────────
1:40:33 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
1:40:32 PM:   "build.command" failed                                        
1:40:32 PM: ────────────────────────────────────────────────────────────────
1:40:32 PM: ​
1:40:32 PM:   Error message
1:40:32 PM:   Command failed with exit code 1: npm run build (https://ntl.fyi/exit-code-1)
1:40:32 PM: ​
1:40:32 PM:   Error location
1:40:32 PM:   In Build command from Netlify app:
1:40:32 PM:   npm run build
1:40:32 PM: ​
1:40:32 PM:   Resolved config
1:40:32 PM:   build:
1:40:32 PM:     command: npm run build
1:40:32 PM:     commandOrigin: ui
1:40:32 PM:     environment:
1:40:32 PM:       - NPM_TOKEN
1:40:32 PM:       - REVIEW_ID
1:40:32 PM:     publish: /opt/build/repo/build
1:40:32 PM:     publishOrigin: ui
1:40:33 PM: Caching artifacts
1:40:33 PM: Started saving node modules
1:40:33 PM: Finished saving node modules
1:40:33 PM: Started saving build plugins
1:40:33 PM: Finished saving build plugins
1:40:33 PM: Started saving pip cache
1:40:33 PM: Finished saving pip cache
1:40:33 PM: Started saving emacs cask dependencies
1:40:33 PM: Finished saving emacs cask dependencies
1:40:33 PM: Started saving maven dependencies
1:40:33 PM: Finished saving maven dependencies
1:40:33 PM: Started saving boot dependencies
1:40:33 PM: Finished saving boot dependencies
1:40:33 PM: Started saving rust rustup cache
1:40:33 PM: Finished saving rust rustup cache
1:40:33 PM: Started saving go dependencies
1:40:33 PM: Finished saving go dependencies
1:40:33 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
1:40:33 PM: Failing build: Failed to build site
1:40:33 PM: Finished processing build request in 39.123196278s

Please let me know how I can identify the cause of the failing build

Hey there! It looks like the error is indicating that you will need to adjust the build command that you have. Have you tried different build commands?

I also encourage you to search the forums for related threads: Search results for 'exit code 2' - Netlify Support Forums

Hi Hilary,

it appears that fixing the issue causing this warning; (1024:3) autoprefixer: start value has mixed support, consider using flex-start instead fixed the build.

I believe that this was incorrectly shown as a warning due to Treating warnings as errors because process.env.CI = true. (P.S. For anyone reading this can be turned off by changing the build command to CI=false npm run build)

Thanks :slight_smile:

Thanks so much for coming back and letting us know! Sharing this solution will help future Forums members who encounter similar situations.

Happy building :rocket: