Deploy issue - Build script returned non-zero exit code: 2

Here we go!

the site deployed several times successfully - until it stopped! I didn’t make any significant updates, besides some layout changes. I have been pulling my hair out, very odd situation indeed. Please help me understand what I did… I’m already deeply humbled.
So much appreciated!!

Full deploy script:
8:07:51 PM: Build ready to start
8:08:05 PM: build-image version: 4c0c1cadee6a31c9bb8d824514030009c4c05c6a (focal)
8:08:05 PM: build-image tag: v4.15.0
8:08:05 PM: buildbot version: 8e21f3a6f94b4bf664f0a5ce69b751fdfc9791bd
8:08:05 PM: Fetching cached dependencies
8:08:05 PM: Starting to download cache of 137.0MB
8:08:06 PM: Finished downloading cache in 1.064141996s
8:08:06 PM: Starting to extract cache
8:08:08 PM: Finished extracting cache in 2.064073324s
8:08:08 PM: Finished fetching cache in 3.191842216s
8:08:08 PM: Starting to prepare the repo for build
8:08:09 PM: Preparing Git Reference refs/heads/master
8:08:09 PM: Parsing package.json dependencies
8:08:11 PM: Section completed: initializing
8:08:11 PM: Starting build script
8:08:11 PM: Installing dependencies
8:08:11 PM: Python version set to 2.7
8:08:11 PM: Started restoring cached node version
8:08:12 PM: Finished restoring cached node version
8:08:12 PM: v16.18.1 is already installed.
8:08:13 PM: Now using node v16.18.1 (npm v8.19.2)
8:08:13 PM: Enabling node corepack
8:08:13 PM: Started restoring cached build plugins
8:08:13 PM: Finished restoring cached build plugins
8:08:13 PM: Attempting ruby version 2.7.2, read from environment
8:08:14 PM: Using ruby version 2.7.2
8:08:14 PM: Using PHP version 8.0
8:08:14 PM: No npm workspaces detected
8:08:14 PM: Started restoring cached node modules
8:08:14 PM: Finished restoring cached node modules
8:08:15 PM: Installing NPM modules using NPM version 8.19.2
8:08:28 PM: added 393 packages, removed 713 packages, changed 516 packages, and audited 1622 packages in 13s
8:08:28 PM: 215 packages are looking for funding
8:08:28 PM: run npm fund for details
8:08:28 PM: 6 high severity vulnerabilities
8:08:28 PM: To address all issues (including breaking changes), run:
8:08:28 PM: npm audit fix --force
8:08:28 PM: Run npm audit for details.
8:08:28 PM: NPM modules installed
8:08:28 PM: Creating package sha
8:08:28 PM: Started restoring cached go cache
8:08:28 PM: Finished restoring cached go cache
8:08:29 PM: Installing Go version 1.19.3 (requested 1.19.x)
8:08:35 PM: unset GOOS;
8:08:35 PM: unset GOARCH;
8:08:35 PM: export GOROOT=‘/opt/buildhome/.gimme/versions/go1.19.3.linux.amd64’;
8:08:35 PM: export PATH=“/opt/buildhome/.gimme/versions/go1.19.3.linux.amd64/bin:${PATH}”;
8:08:35 PM: go version >&2;
8:08:35 PM: export GIMME_ENV=“/opt/buildhome/.gimme/env/go1.19.3.linux.amd64.env”
8:08:35 PM: go version go1.19.3 linux/amd64
8:08:36 PM: Detected 1 framework(s)
8:08:36 PM: “create-react-app” at version “5.0.1”
8:08:36 PM: Installing missing commands
8:08:36 PM: Verify run directory
8:08:38 PM: ​
8:08:38 PM: ────────────────────────────────────────────────────────────────
8:08:38 PM: Netlify Build
8:08:38 PM: ────────────────────────────────────────────────────────────────
8:08:38 PM: ​
8:08:38 PM: ❯ Version
8:08:38 PM: @netlify/build 28.4.0
8:08:38 PM: ​
8:08:38 PM: ❯ Flags
8:08:38 PM: baseRelDir: true
8:08:38 PM: buildId: 63819117354941000969a1fe
8:08:38 PM: deployId: 63819117354941000969a200
8:08:38 PM: ​
8:08:38 PM: ❯ Current directory
8:08:38 PM: /opt/build/repo
8:08:38 PM: ​
8:08:38 PM: ❯ Config file
8:08:38 PM: No config file was defined: using default values.
8:08:38 PM: ​
8:08:38 PM: ❯ Context
8:08:38 PM: production
8:08:38 PM: ​
8:08:38 PM: ────────────────────────────────────────────────────────────────
8:08:38 PM: 1. Build command from Netlify app
8:08:38 PM: ────────────────────────────────────────────────────────────────
8:08:38 PM: ​
8:08:38 PM: $ npm run build
8:08:38 PM: > ecommerce-website-1@0.1.0 build
8:08:38 PM: > react-scripts build
8:08:39 PM: Creating an optimized production build…
8:08:53 PM:
8:08:53 PM: Treating warnings as errors because process.env.CI = true.
8:08:53 PM: Most CI servers set it automatically.
8:08:53 PM:
8:08:53 PM: Failed to compile.
8:08:53 PM:
8:08:53 PM: Warning
8:08:53 PM: (2482:3) autoprefixer: Replace color-adjust to print-color-adjust. The color-adjust shorthand is currently deprecated.
8:08:53 PM: ​
8:08:53 PM: ────────────────────────────────────────────────────────────────
8:08:53 PM: “build.command” failed
8:08:53 PM: ────────────────────────────────────────────────────────────────
8:08:53 PM: ​
8:08:53 PM: Error message
8:08:53 PM: Command failed with exit code 1: npm run build (Search results for '"non-zero exit code: 1"' - Netlify Support Forums)
8:08:53 PM: ​
8:08:54 PM: Creating deploy upload records
8:08:53 PM: Error location
8:08:53 PM: In Build command from Netlify app:
8:08:53 PM: npm run build
8:08:54 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)
8:08:53 PM: ​
8:08:53 PM: Resolved config
8:08:53 PM: build:
8:08:53 PM: command: npm run build
8:08:53 PM: commandOrigin: ui
8:08:53 PM: publish: /opt/build/repo/build
8:08:53 PM: publishOrigin: ui
8:08:54 PM: Caching artifacts
8:08:54 PM: Started saving node modules
8:08:54 PM: Finished saving node modules
8:08:54 PM: Started saving build plugins
8:08:54 PM: Finished saving build plugins
8:08:54 PM: Started saving pip cache
8:08:54 PM: Finished saving pip cache
8:08:54 PM: Started saving emacs cask dependencies
8:08:54 PM: Finished saving emacs cask dependencies
8:08:54 PM: Started saving maven dependencies
8:08:54 PM: Finished saving maven dependencies
8:08:54 PM: Started saving boot dependencies
8:08:54 PM: Finished saving boot dependencies
8:08:54 PM: Started saving rust rustup cache
8:08:54 PM: Finished saving rust rustup cache
8:08:54 PM: Started saving go dependencies
8:08:54 PM: Finished saving go dependencies
8:08:54 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
8:08:54 PM: Failing build: Failed to build site
8:08:54 PM: Finished processing build request in 49.03893817s

Hi @nruijling,

Thanks for reaching out and welcome to Netlify’s Support Forums!

Looking at the latest build, I see these errors here:

9:00:18 PM: Failed to compile.
9:00:18 PM: 
9:00:18 PM: Warning
9:00:18 PM: (2482:3) autoprefixer: Replace color-adjust to print-color-adjust. The color-adjust shorthand is currently deprecated.
9:00:18 PM: [eslint]
9:00:18 PM: src/pages/Home.jsx
9:00:18 PM:   Line 3:8:  'LiveAuction' is defined but never used    no-unused-vars
9:00:18 PM:   Line 4:8:  'SellerSection' is defined but never used  no-unused-vars
9:00:18 PM:   Line 5:8:  'Trending' is defined but never used       no-unused-vars

Would you be able resolve those errors to see if your build is then successful?

Melvin,

I appreciate your response! Very quick response also.
I’m using VSCode and tried to do Ctrl + F to find the color-adjust line of code, but it’s nowhere to be found. It suggests it is in the file pages\home.jsx, but it’s not there. The home.jsx is only 6 lines, so it’s hard to overlook.

The puzzling thing is that this project used to run just fine, and after only minor text changes I’m having issues.

I will keep looking, do you have any other suggestions?

@Melvin Thanks so much!

The problem is this part.

Change your build command to CI= npm run build.

1 Like

Thank you! That worked!

Hi @nruijling :wave:t6: , welcome back to the forums! Thanks for letting us know Hrishikesh’s solution was able to help you resolve your problem. We greatly appreciate the feedback. This will help other users in the future. :smiling_face_with_three_hearts: