I can't deploy my site non-zero exit code: 2

11:44:36 AM: ❯ Version
11:44:36 AM: @netlify/build 29.2.1
11:44:36 AM: ​
11:44:36 AM: ❯ Flags
11:44:36 AM: baseRelDir: true
11:44:36 AM: buildId: 63a2e37e1643a562c0f2abd0
11:44:36 AM: deployId: 63a2e37e1643a562c0f2abd2
11:44:36 AM: ​
11:44:36 AM: ❯ Current directory
11:44:36 AM: /opt/build/repo
11:44:36 AM: ​
11:44:36 AM: ❯ Config file
11:44:36 AM: No config file was defined: using default values.
11:44:36 AM: ​
11:44:36 AM: ❯ Context
11:44:36 AM: production
11:44:36 AM: ​
11:44:36 AM: 1. Build command from Netlify app
11:44:36 AM: ────────────────────────────────────────────────────────────────
11:44:36 AM: ​
11:44:36 AM: $ npm run build
11:44:36 AM: > react-portfolio@0.1.0 build
11:44:36 AM: > react-scripts build
11:44:37 AM: Creating an optimized production build…
11:44:49 AM:
11:44:49 AM: Treating warnings as errors because process.env.CI = true.
11:44:49 AM: Most CI servers set it automatically.
11:44:49 AM:
11:44:49 AM: Failed to compile.
11:44:49 AM:
11:44:49 AM: [eslint]
11:44:49 AM: src/components/Form.jsx
11:44:49 AM: Line 20:12: ‘mailSent’ is defined but never used no-unused-vars
11:44:49 AM: ​
11:44:49 AM: “build.command” failed
11:44:49 AM: ────────────────────────────────────────────────────────────────
11:44:49 AM: ​
11:44:49 AM: Error message
11:44:49 AM: Command failed with exit code 1: npm run build (Search results for '"non-zero exit code: 1"' - Netlify Support Forums)
11:44:49 AM: ​
11:44:49 AM: Error location
11:44:49 AM: In Build command from Netlify app:
11:44:49 AM: npm run build
11:44:49 AM: ​
11:44:49 AM: Resolved config
11:44:49 AM: build:
11:44:49 AM: command: npm run build
11:44:49 AM: commandOrigin: ui
11:44:49 AM: publish: /opt/build/repo/build
11:44:49 AM: publishOrigin: ui
11:44:50 AM: Caching artifacts
11:44:50 AM: Started saving node modules
11:44:50 AM: Finished saving node modules
11:44:50 AM: Started saving build plugins
11:44:50 AM: Failed during stage ‘building site’: Build script returned non-zero exit code: 2 (Search results for '"non-zero exit code: 2"' - Netlify Support Forums)
11:44:50 AM: Finished saving build plugins
11:44:50 AM: Started saving pip cache
11:44:50 AM: Finished saving pip cache
11:44:50 AM: Started saving emacs cask dependencies
11:44:50 AM: Finished saving emacs cask dependencies
11:44:50 AM: Started saving maven dependencies
11:44:50 AM: Finished saving maven dependencies
11:44:50 AM: Started saving boot dependencies
11:44:50 AM: Finished saving boot dependencies
11:44:50 AM: Started saving rust rustup cache
11:44:50 AM: Finished saving rust rustup cache
11:44:50 AM: Started saving go dependencies
11:44:50 AM: Finished saving go dependencies
11:44:50 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
11:44:50 AM: Failing build: Failed to build site
11:44:50 AM: Finished processing build request in 34.865835128s

Hiya @legorille2021 :wave:t6: thanks for reaching out and welcome to the Netlify forums!

Sorry to hear your build is failing. Have you got it working locally first? If not please get it working locally and debug your code.

If it is working locally and failing to deploy on Netlify can you please check out this resource first. See if that helps you resolve your issue…

If those resources don’t get you on the right track, please share these additional details so we can look into your experience further:

  • the name of your build instance: “example-jones.netlify.com 1
  • your project repo
  • what you have already tried
  • your build settings
  • the expected behaviour you wish to see

Thanks so much!