Site Deploy Failed - React App Build Failed - Exit code 1 & 2

Hello. I tried to deploy a React App and there was an error on build. I have run “npm run build” in my local env and it worked without issue. Any help would be appreciated.

1:26:52 PM: build-image version: c0621868af5001023389eeaa9dbfbbaf313f67e2 (focal)
1:26:52 PM: buildbot version: c0621868af5001023389eeaa9dbfbbaf313f67e2
1:26:52 PM: Fetching cached dependencies
1:26:52 PM: Failed to fetch cache, continuing with build
1:26:52 PM: Starting to prepare the repo for build
1:26:52 PM: No cached dependencies found. Cloning fresh repo
1:26:52 PM: git clone --filter=blob:none https://github.com/Dean-Baylem/trivia-quiz
1:26:52 PM: Preparing Git Reference refs/heads/master
1:26:53 PM: Parsing package.json dependencies
1:26:54 PM: Starting build script
1:26:54 PM: Installing dependencies
1:26:54 PM: Python version set to 2.7
1:26:55 PM: v16.19.1 is already installed.
1:26:55 PM: Now using node v16.19.1 (npm v8.19.3)
1:26:55 PM: Enabling Node.js Corepack
1:26:55 PM: Started restoring cached build plugins
1:26:55 PM: Finished restoring cached build plugins
1:26:55 PM: Attempting Ruby version 2.7.2, read from environment
1:26:56 PM: Using Ruby version 2.7.2
1:26:56 PM: Using PHP version 8.0
1:26:56 PM: Started restoring cached corepack dependencies
1:26:56 PM: Finished restoring cached corepack dependencies
1:26:56 PM: No npm workspaces detected
1:26:56 PM: Started restoring cached node modules
1:26:56 PM: Finished restoring cached node modules
1:26:56 PM: Installing npm packages using npm version 8.19.3
1:27:01 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: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#browser_compatibility
1:27:01 PM: npm WARN deprecated sourcemap-codec@1.4.8: Please use @jridgewell/sourcemap-codec instead
1:27:01 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:27:04 PM: npm WARN deprecated svgo@1.3.2: This SVGO version is no longer supported. Upgrade to v2.x.x.
1:27:08 PM: added 1470 packages, and audited 1471 packages in 12s
1:27:08 PM: 231 packages are looking for funding
1:27:08 PM:   run `npm fund` for details
1:27:08 PM: 6 high severity vulnerabilities
1:27:08 PM: To address all issues (including breaking changes), run:
1:27:08 PM:   npm audit fix --force
1:27:08 PM: Run `npm audit` for details.
1:27:08 PM: npm packages installed
1:27:08 PM: Started restoring cached go cache
1:27:08 PM: Finished restoring cached go cache
1:27:08 PM: go version go1.19.6 linux/amd64
1:27:09 PM: Detected 1 framework(s)
1:27:09 PM: "create-react-app" at version "5.0.1"
1:27:09 PM: Section completed: initializing
1:27:10 PM: ​
1:27:10 PM:   Netlify Build                                                 
1:27:10 PM: ────────────────────────────────────────────────────────────────
1:27:10 PM: ​
1:27:10 PM: ❯ Version
1:27:10 PM:   @netlify/build 29.5.8
1:27:10 PM: ​
1:27:10 PM: ❯ Flags
1:27:10 PM:   baseRelDir: true
1:27:10 PM:   buildId: 63fc310a9a249e0619af944d
1:27:10 PM:   deployId: 63fc310a9a249e0619af944f
1:27:10 PM: ​
1:27:10 PM: ❯ Current directory
1:27:10 PM:   /opt/build/repo
1:27:10 PM: ​
1:27:10 PM: ❯ Config file
1:27:10 PM:   No config file was defined: using default values.
1:27:10 PM: ​
1:27:10 PM: ❯ Context
1:27:10 PM:   production
1:27:10 PM: ​
1:27:10 PM:   1. Build command from Netlify app                             
1:27:10 PM: ────────────────────────────────────────────────────────────────
1:27:10 PM: ​
1:27:10 PM: $ npm run build
1:27:10 PM: > trivia-quiz@0.1.0 build
1:27:10 PM: > react-scripts build
1:27:11 PM: Creating an optimized production build...
1:27:17 PM: 
1:27:17 PM: Treating warnings as errors because process.env.CI = true.
1:27:17 PM: Most CI servers set it automatically.
1:27:17 PM: 
1:27:17 PM: Failed to compile.
1:27:17 PM: 
1:27:17 PM: [eslint]
1:27:17 PM: src/Components/App.js
1:27:17 PM:   Line 65:3:    React Hook useEffect contains a call to 'setGameOver'. Without a list of dependencies, this can lead to an infinite chain of updates. To fix this, pass [previousCategories.length] as a second argument to the useEffect Hook                             react-hooks/exhaustive-deps
1:27:17 PM:   Line 75:3:    React Hook useEffect contains a call to 'setMessage'. Without a list of dependencies, this can lead to an infinite chain of updates. To fix this, pass [quizStart, totalScore, score] as a second argument to the useEffect Hook                           react-hooks/exhaustive-deps
1:27:17 PM:   Line 83:3:    React Hook useEffect contains a call to 'setInstructions'. Without a list of dependencies, this can lead to an infinite chain of updates. To fix this, pass [removeCatCards] as a second argument to the useEffect Hook                                    react-hooks/exhaustive-deps
1:27:17 PM:   Line 93:3:    React Hook useEffect contains a call to 'setCurrentQuestion'. Without a list of dependencies, this can lead to an infinite chain of updates. To fix this, pass [makeQuestion, questions, questionIndex, score] as a second argument to the useEffect Hook  react-hooks/exhaustive-deps
1:27:17 PM:   Line 217:12:  'testClick' is defined but never used                                                                                                                                                                                                                      no-unused-vars
1:27:17 PM:   Line 307:1:   Block is redundant                                                                                                                                                                                                                                         no-lone-blocks
1:27:17 PM: src/Components/CategoryCard/CategoryCard.jsx
1:27:17 PM:   Line 13:5:  React Hook useEffect contains a call to 'setChosen'. Without a list of dependencies, this can lead to an infinite chain of updates. To fix this, pass [props.restart] as a second argument to the useEffect Hook  react-hooks/exhaustive-deps
1:27:17 PM: src/Components/GameOverModal/GameOverModal.jsx
1:27:17 PM:   Line 49:20:  Comments inside children section of tag should be placed inside braces  react/jsx-no-comment-textnodes
1:27:17 PM: ​
1:27:17 PM:   "build.command" failed                                        
1:27:17 PM: ────────────────────────────────────────────────────────────────
1:27:17 PM: ​
1:27:17 PM:   Error message
1:27:17 PM:   Command failed with exit code 1: npm run build (https://ntl.fyi/exit-code-1)
1:27:17 PM: ​
1:27:17 PM:   Error location
1:27:17 PM:   In Build command from Netlify app:
1:27:17 PM:   npm run build
1:27:17 PM: ​
1:27:18 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
1:27:17 PM:   Resolved config
1:27:17 PM:   build:
1:27:17 PM:     command: npm run build
1:27:17 PM:     commandOrigin: ui
1:27:17 PM:     publish: /opt/build/repo/build
1:27:17 PM:     publishOrigin: ui
1:27:17 PM: Caching artifacts
1:27:17 PM: Started saving node modules
1:27:17 PM: Finished saving node modules
1:27:17 PM: Started saving build plugins
1:27:17 PM: Finished saving build plugins
1:27:17 PM: Started saving corepack cache
1:27:17 PM: Finished saving corepack cache
1:27:17 PM: Started saving pip cache
1:27:17 PM: Finished saving pip cache
1:27:17 PM: Started saving emacs cask dependencies
1:27:17 PM: Finished saving emacs cask dependencies
1:27:17 PM: Started saving maven dependencies
1:27:17 PM: Finished saving maven dependencies
1:27:17 PM: Started saving boot dependencies
1:27:17 PM: Finished saving boot dependencies
1:27:17 PM: Started saving rust rustup cache
1:27:17 PM: Finished saving rust rustup cache
1:27:17 PM: Started saving go dependencies
1:27:17 PM: Finished saving go dependencies
1:27:18 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
1:27:18 PM: Failing build: Failed to build site
1:27:18 PM: Finished processing build request in 26.297s

@Dean-Baylem See this answer as your issue is the same:

Hi @Dean-Baylem :wave:t6: ,

Thank you so much for reach out. What is your site name?