1:09:17 PM: Build failed due to a user error: Build script returned non-zero exit code: 2

Having issues deploying my latest push. I have no idea how to fix it. It runs perfectly fine locally.

1:08:37 PM: build-image version: 91488c6c0412f5c1c00fb34eff5c1fc41a32bce9 (focal)
1:08:37 PM: buildbot version: 91488c6c0412f5c1c00fb34eff5c1fc41a32bce9
1:08:37 PM: Fetching cached dependencies
1:08:37 PM: Starting to download cache of 108.7MB
1:08:38 PM: Finished downloading cache in 697ms
1:08:38 PM: Starting to extract cache
1:08:39 PM: Finished extracting cache in 1.024s
1:08:39 PM: Finished fetching cache in 1.772s
1:08:39 PM: Starting to prepare the repo for build
1:08:40 PM: Preparing Git Reference refs/heads/gh-pages
1:08:41 PM: Parsing package.json dependencies
1:08:43 PM: Starting to install dependencies
1:08:43 PM: Python version set to 3.8
1:08:43 PM: Attempting Ruby version 2.7.2, read from environment
1:08:44 PM: Using Ruby version 2.7.2
1:08:44 PM: Started restoring cached go cache
1:08:44 PM: Finished restoring cached go cache
1:08:44 PM: Installing Go version 1.19.5 (requested 1.19.5)
1:08:49 PM: go version go1.19.5 linux/amd64
1:08:49 PM: Using PHP version 8.0
1:08:50 PM: Started restoring cached Node.js version
1:08:50 PM: Finished restoring cached Node.js version
1:08:51 PM: v16.20.0 is already installed.
1:08:51 PM: Now using node v16.20.0 (npm v8.19.4)
1:08:51 PM: Enabling Node.js Corepack
1:08:51 PM: Started restoring cached build plugins
1:08:51 PM: Finished restoring cached build plugins
1:08:51 PM: Started restoring cached corepack dependencies
1:08:51 PM: Finished restoring cached corepack dependencies
1:08:51 PM: No npm workspaces detected
1:08:51 PM: Started restoring cached node modules
1:08:51 PM: Finished restoring cached node modules
1:08:52 PM: Installing npm packages using npm version 8.19.4
1:08:56 PM: npm WARN deprecated w3c-hr-time@1.0.2: Use your platform’s native performance.now() and performance.timeOrigin.
npm WARN deprecated stable@0.1.8: Modern JS already guarantees Array#sort() is a stable sort, so this library is deprecated. See the compatibility table on MDN: Array.prototype.sort() - JavaScript | MDN
1:08:57 PM: npm WARN deprecated sourcemap-codec@1.4.8: Please use @jridgewell/sourcemap-codec instead
1:08:57 PM: npm WARN deprecated rollup-plugin-terser@7.0.2: This package has been deprecated and is no longer maintained. Please use @rollup/plugin-terser
1:09:01 PM: npm WARN deprecated svgo@1.3.2: This SVGO version is no longer supported. Upgrade to v2.x.x.
1:09:07 PM: added 3 packages, removed 3 packages, changed 1485 packages, and audited 1501 packages in 15s
1:09:07 PM: 236 packages are looking for funding
1:09:07 PM: run npm fund for details
1:09:07 PM: 6 high severity vulnerabilities
1:09:07 PM: To address all issues (including breaking changes), run:
1:09:07 PM: npm audit fix --force
1:09:07 PM: Run npm audit for details.
1:09:07 PM: npm packages installed
1:09:07 PM: Install dependencies script success
1:09:07 PM: Starting build script
1:09:08 PM: Detected 1 framework(s)
1:09:08 PM: “create-react-app” at version “5.0.1”
1:09:08 PM: Section completed: initializing
1:09:09 PM: ​
1:09:09 PM: Netlify Build
1:09:09 PM: ────────────────────────────────────────────────────────────────
1:09:09 PM: ​
1:09:09 PM: ❯ Version
1:09:09 PM: @netlify/build 29.9.2
1:09:09 PM: ​
1:09:09 PM: ❯ Flags
1:09:09 PM: baseRelDir: true
1:09:09 PM: buildId: 643c2b921692d900082f1556
1:09:09 PM: deployId: 643c2b921692d900082f1558
1:09:09 PM: ​
1:09:09 PM: ❯ Current directory
1:09:09 PM: /opt/build/repo
1:09:09 PM: ​
1:09:09 PM: ❯ Config file
1:09:09 PM: No config file was defined: using default values.
1:09:09 PM: ​
1:09:09 PM: ❯ Context
1:09:09 PM: production
1:09:09 PM: ​
1:09:09 PM: 1. Build command from Netlify app
1:09:09 PM: ────────────────────────────────────────────────────────────────
1:09:09 PM: ​
1:09:09 PM: $ npm run build
1:09:09 PM: > tko_blog@0.1.0 build

1:09:09 PM: > react-scripts build
1:09:10 PM: Creating an optimized production build…
1:09:16 PM:
1:09:16 PM: Treating warnings as errors because process.env.CI = true.
1:09:16 PM: Most CI servers set it automatically.
1:09:16 PM:
1:09:16 PM: Failed to compile.
1:09:16 PM:
1:09:16 PM: [eslint]
1:09:16 PM: src/pages/HomePage.js
1:09:16 PM: Line 1:27: ‘useEffect’ is defined but never used no-unused-vars
1:09:16 PM: ​
1:09:16 PM: “build.command” failed
1:09:16 PM: ────────────────────────────────────────────────────────────────
1:09:16 PM: ​
1:09:16 PM: Error message
1:09:16 PM: Command failed with exit code 1: npm run build (Search results for '"non-zero exit code: 1"' - Netlify Support Forums)
1:09:16 PM: ​
1:09:16 PM: Error location
1:09:16 PM: In Build command from Netlify app:
1:09:16 PM: npm run build
1:09:16 PM: ​
1:09:16 PM: Resolved config
1:09:16 PM: build:
1:09:16 PM: command: npm run build
1:09:16 PM: commandOrigin: ui
1:09:16 PM: publish: /opt/build/repo/build
1:09:16 PM: publishOrigin: ui
1:09:16 PM: Caching artifacts
1:09:16 PM: Started saving node modules
1:09:16 PM: Finished saving node modules
1:09:16 PM: Started saving build plugins
1:09:16 PM: Finished saving build plugins
1:09:17 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)
1:09:16 PM: Started saving corepack cache
1:09:16 PM: Finished saving corepack cache
1:09:16 PM: Started saving pip cache
1:09:16 PM: Finished saving pip cache
1:09:16 PM: Started saving emacs cask dependencies
1:09:16 PM: Finished saving emacs cask dependencies
1:09:16 PM: Started saving maven dependencies
1:09:16 PM: Finished saving maven dependencies
1:09:16 PM: Started saving boot dependencies
1:09:16 PM: Finished saving boot dependencies
1:09:16 PM: Started saving rust rustup cache
1:09:16 PM: Finished saving rust rustup cache
1:09:16 PM: Started saving go dependencies
1:09:16 PM: Finished saving go dependencies
1:09:17 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
1:09:17 PM: Failing build: Failed to build site
1:09:17 PM: Finished processing build request in 39.735s

The error is mentioned here - there are several posts about this. Change your build command to CI= npm run build.

thank you! I’m new to web dev so I didn’t know where or how to fix it.