Gatsby Build failed due to a user error: Build script returned non-zero exit code: 2

Hello , I’m facing this issue Build failed due to a user error: Build script returned non-zero exit code: 2. and I can’t deploy my Gatsby Application ! - Please can someone help, it is urgent.

8:42:28 PM: “build.command” failed
8:42:28 PM: ────────────────────────────────────────────────────────────────
8:42:28 PM: ​
8:42:28 PM: Error message
8:42:28 PM: Command failed with exit code 1: CI= npm run build (Search results for '"non-zero exit code: 1"' - Netlify Support Forums)
8:42:28 PM: ​
8:42:28 PM: Error location
8:42:28 PM: In Build command from Netlify app:
8:42:28 PM: CI= npm run build
8:42:28 PM: ​
8:42:28 PM: Resolved config
8:42:28 PM: build:
8:42:28 PM: command: CI= npm run build
8:42:28 PM: commandOrigin: ui
8:42:28 PM: environment:
8:42:28 PM: - MAILCHIMP_END_POINT
8:42:28 PM: - NETLIFY_EMAILS_DIRECTORY
8:42:28 PM: - NETLIFY_EMAILS_PROVIDER
8:42:28 PM: - NETLIFY_EMAILS_PROVIDER_API_KEY
8:42:28 PM: - NETLIFY_EMAILS_SECRET
8:42:28 PM: - NETLIFY_GRAPH_TOKEN
8:42:28 PM: - NODE_VERSION
8:42:28 PM: - ONEGRAPH_AUTHLIFY_TOKEN
8:42:28 PM: - REVIEW_ID
8:42:28 PM: publish: /opt/build/repo/public
8:42:28 PM: publishOrigin: ui
8:42:29 PM: functions:
8:42:29 PM: emails:
8:42:29 PM: external_node_modules:
8:42:29 PM: - node-fetch@2
8:42:29 PM: included_files:
8:42:29 PM: - ./emails/**
plugins:
- inputs: {}
origin: ui
package: ‘@netlify/plugin-gatsby’
- inputs: {}
origin: ui
package: ‘@netlify/plugin-emails’
Caching artifacts
Started saving node modules
Finished saving node modules
Started saving build plugins
8:42:29 PM: Finished saving build plugins
8:42:29 PM: Started saving corepack cache
8:42:29 PM: Finished saving corepack cache
8:42:29 PM: Started saving yarn cache
8:42:52 PM: Finished saving yarn cache
8:42:52 PM: Started saving pip cache
8:42:52 PM: Finished saving pip cache
8:42:52 PM: Started saving emacs cask dependencies
8:42:52 PM: Finished saving emacs cask dependencies
8:42:52 PM: Started saving maven dependencies
8:42:52 PM: Finished saving maven dependencies
8:42:52 PM: Started saving boot dependencies
8:42:52 PM: Finished saving boot dependencies
8:42:52 PM: Started saving rust rustup cache
8:42:52 PM: Finished saving rust rustup cache
8:42:52 PM: Started saving go dependencies
8:42:52 PM: Finished saving go dependencies
8:42:55 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
8:42:55 PM: Failing build: Failed to build site
8:42:56 PM: Finished processing build request in 5m25.982s

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

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

Please keep in mind debugging code is outside the realm of support so if it’s not working locally first I’d encourage you to fix your code. ( :