Build Failed with “non-zero exit code: 2” error

10:25:56 AM: Build ready to start
10:26:03 AM: build-image version: d7b3dbfb0846505993c9a131894d1858074c90b4 (focal)
10:26:03 AM: build-image tag: v4.10.1
10:26:03 AM: buildbot version: 1c362ef848ac5e35535bdb572ebca893db28c8a0
10:26:03 AM: Fetching cached dependencies
10:26:03 AM: Starting to download cache of 138.7MB
10:26:04 AM: Finished downloading cache in 871.928155ms
10:26:04 AM: Starting to extract cache
10:26:05 AM: Finished extracting cache in 1.348847977s
10:26:05 AM: Finished fetching cache in 2.278157967s
10:26:05 AM: Starting to prepare the repo for build
10:26:06 AM: Preparing Git Reference refs/heads/main
10:26:06 AM: Parsing package.json dependencies
10:26:07 AM: Starting build script
10:26:07 AM: Installing dependencies
10:26:07 AM: Python version set to 2.7
10:26:07 AM: Started restoring cached node version
10:26:08 AM: Finished restoring cached node version
10:26:08 AM: v16.17.0 is already installed.
10:26:08 AM: Now using node v16.17.0 (npm v8.15.0)
10:26:08 AM: Started restoring cached build plugins
10:26:08 AM: Finished restoring cached build plugins
10:26:08 AM: Attempting ruby version 2.7.2, read from environment
10:26:09 AM: Using ruby version 2.7.2
10:26:09 AM: Using PHP version 8.0
10:26:09 AM: No npm workspaces detected
10:26:09 AM: Started restoring cached node modules
10:26:09 AM: Finished restoring cached node modules
10:26:10 AM: Installing NPM modules using NPM version 8.15.0
10:26:10 AM: npm WARN config tmp This setting is no longer used.  npm stores temporary files in a special
10:26:10 AM: npm WARN config location in the cache, and they are managed by
10:26:10 AM: npm WARN config     [`cacache`](http://npm.im/cacache).
10:26:10 AM: npm WARN config tmp This setting is no longer used.  npm stores temporary files in a special
10:26:10 AM: npm WARN config location in the cache, and they are managed by
10:26:10 AM: npm WARN config     [`cacache`](http://npm.im/cacache).
10:26:14 AM: added 116 packages, changed 8 packages, and audited 1583 packages in 4s
10:26:14 AM: 213 packages are looking for funding
10:26:14 AM:   run `npm fund` for details
10:26:14 AM: 6 high severity vulnerabilities
10:26:14 AM: To address all issues (including breaking changes), run:
10:26:14 AM:   npm audit fix --force
10:26:14 AM: Run `npm audit` for details.
10:26:14 AM: NPM modules installed
10:26:15 AM: npm WARN config tmp This setting is no longer used.  npm stores temporary files in a special
10:26:15 AM: npm WARN config location in the cache, and they are managed by
10:26:15 AM: npm WARN config     [`cacache`](http://npm.im/cacache).
10:26:15 AM: Started restoring cached go cache
10:26:15 AM: Finished restoring cached go cache
10:26:15 AM: Installing Go version 1.17 (requested 1.17)
10:26:19 AM: unset GOOS;
10:26:19 AM: unset GOARCH;
10:26:19 AM: export GOROOT='/opt/buildhome/.gimme/versions/go1.17.linux.amd64';
10:26:19 AM: export PATH="/opt/buildhome/.gimme/versions/go1.17.linux.amd64/bin:${PATH}";
10:26:19 AM: go version >&2;
10:26:19 AM: export GIMME_ENV="/opt/buildhome/.gimme/env/go1.17.linux.amd64.env"
10:26:19 AM: go version go1.17 linux/amd64
10:26:19 AM: Installing missing commands
10:26:19 AM: Verify run directory
10:26:20 AM: ​
10:26:20 AM: ────────────────────────────────────────────────────────────────
10:26:20 AM:   Netlify Build                                                 
10:26:20 AM: ────────────────────────────────────────────────────────────────
10:26:20 AM: ​
10:26:20 AM: ❯ Version
10:26:20 AM:   @netlify/build 27.18.4
10:26:20 AM: ​
10:26:20 AM: ❯ Flags
10:26:20 AM:   baseRelDir: true
10:26:20 AM:   buildId: 632a6824290bbf0008a33d25
10:26:20 AM:   deployId: 632a6824290bbf0008a33d27
10:26:20 AM: ​
10:26:20 AM: ❯ Current directory
10:26:20 AM:   /opt/build/repo
10:26:20 AM: ​
10:26:20 AM: ❯ Config file
10:26:20 AM:   No config file was defined: using default values.
10:26:20 AM: ​
10:26:20 AM: ❯ Context
10:26:20 AM:   production
10:26:20 AM: ​
10:26:20 AM: ────────────────────────────────────────────────────────────────
10:26:20 AM:   1. Build command from Netlify app                             
10:26:20 AM: ────────────────────────────────────────────────────────────────
10:26:20 AM: ​
10:26:20 AM: $ CI= npm run build
10:26:20 AM: npm WARN config tmp This setting is no longer used.  npm stores temporary files in a special
10:26:20 AM: npm WARN config location in the cache, and they are managed by
10:26:20 AM: npm WARN config     [`cacache`](http://npm.im/cacache).
10:26:20 AM: > destinationizer@0.1.0 build
10:26:20 AM: > react-scripts build
10:26:21 AM: Creating an optimized production build...
10:26:23 AM: Failed to compile.
10:26:23 AM: 
10:26:23 AM: Module not found: Error: Can't resolve './Components/Search/SearchForm' in '/opt/build/repo/src'
10:26:23 AM: ​
10:26:23 AM: ────────────────────────────────────────────────────────────────
10:26:23 AM:   "build.command" failed                                        
10:26:23 AM: ────────────────────────────────────────────────────────────────
10:26:23 AM: ​
10:26:23 AM:   Error message
10:26:23 AM:   Command failed with exit code 1: CI= npm run build (https://ntl.fyi/exit-code-1)
10:26:23 AM: ​
10:26:23 AM:   Error location
10:26:23 AM:   In Build command from Netlify app:
10:26:23 AM:   CI= npm run build
10:26:23 AM: ​
10:26:23 AM:   Resolved config
10:26:23 AM:   build:
10:26:23 AM:     command: CI= npm run build
10:26:23 AM:     commandOrigin: ui
10:26:23 AM:     environment:
10:26:23 AM:       - REACT_APP_AUTH_KEY
10:26:23 AM:     publish: /opt/build/repo/build
10:26:23 AM:     publishOrigin: ui
10:26:23 AM: Caching artifacts
10:26:23 AM: Started saving node modules
10:26:23 AM: Finished saving node modules
10:26:23 AM: Started saving build plugins
10:26:23 AM: Finished saving build plugins
10:26:23 AM: Started saving pip cache
10:26:23 AM: Finished saving pip cache
10:26:23 AM: Started saving emacs cask dependencies
10:26:23 AM: Finished saving emacs cask dependencies
10:26:23 AM: Started saving maven dependencies
10:26:23 AM: Finished saving maven dependencies
10:26:23 AM: Started saving boot dependencies
10:26:23 AM: Finished saving boot dependencies
10:26:23 AM: Started saving rust rustup cache
10:26:23 AM: Finished saving rust rustup cache
10:26:23 AM: Started saving go dependencies
10:26:23 AM: Finished saving go dependencies
10:26:23 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
10:26:23 AM: Creating deploy upload records
10:26:23 AM: Failing build: Failed to build site
10:26:23 AM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
10:26:23 AM: Finished processing build request in 20.35179949s

Hi there, glad you found us :wave: before we can help you, we need a little more information on the issues you are facing.

First, have you looked through this resource? It is a compilation of all of our build and deploy resources. This is a good starting point.

If you have worked through those guides and are still encountering issues please share the following information:

  • the name of your build instance: “example-jones.netlify.com
  • what you have already tried
  • any error messages you have received in your terminal window or in the developer console
  • No error messages in my terminal window
  • Name of build instance: https://destinationizer.netlify.app/
  • I have tried changing my Environment Variables in Deployment site settings on netlify to fix error 2, but nothing has worked.

Try checking: