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 site.

11:02:28 AM: Build ready to start
11:02:31 AM: build-image version: 122b31996ccaffd45d820a452d6227f8312110cc (focal)
11:02:31 AM: build-image tag: v4.5.3
11:02:31 AM: buildbot version: c68dbedb54f97d2ade6b8aa44f524f50c2bf9351
11:02:31 AM: Fetching cached dependencies
11:02:32 AM: Failed to fetch cache, continuing with build
11:02:32 AM: Starting to prepare the repo for build
11:02:32 AM: No cached dependencies found. Cloning fresh repo
11:02:32 AM: git clone https://github.com/vasnas89/cryptodaucks
11:02:32 AM: Preparing Git Reference refs/heads/main
11:02:32 AM: Parsing package.json dependencies
11:02:33 AM: Different build dir detected, going to use the one specified in the Netlify configuration file: ‘’ versus ‘/’ in the Netlify UI
11:02:34 AM: Starting build script
11:02:34 AM: Installing dependencies
11:02:34 AM: Python version set to 2.7
11:02:35 AM: Downloading and installing node v16.14.0…
11:02:35 AM: Downloading https://nodejs.org/dist/v16.14.0/node-v16.14.0-linux-x64.tar.xz
11:02:35 AM: Computing checksum with sha256sum
11:02:36 AM: Checksums matched!
11:02:39 AM: Now using node v16.14.0 (npm v8.3.1)
11:02:39 AM: Started restoring cached build plugins
11:02:39 AM: Finished restoring cached build plugins
11:02:39 AM: Attempting ruby version 2.7.2, read from environment
11:02:41 AM: Using ruby version 2.7.2
11:02:41 AM: Using PHP version 8.0
11:02:41 AM: Started restoring cached go cache
11:02:41 AM: Finished restoring cached go cache
11:02:42 AM: go version go1.16.5 linux/amd64
11:02:42 AM: go version go1.16.5 linux/amd64
11:02:42 AM: Installing missing commands
11:02:42 AM: Verify run directory
11:02:44 AM: ​
11:02:44 AM: ────────────────────────────────────────────────────────────────
11:02:44 AM: Netlify Build
11:02:44 AM: ────────────────────────────────────────────────────────────────
11:02:44 AM: ​
11:02:44 AM: ❯ Version
11:02:44 AM: @netlify/build 26.3.14
11:02:44 AM: ​
11:02:44 AM: ❯ Flags
11:02:44 AM: baseRelDir: true
11:02:44 AM: buildId: 622494c432fd966efc54b0a5
11:02:44 AM: deployId: 622494c432fd966efc54b0a7
11:02:44 AM: ​
11:02:44 AM: ❯ Current directory
11:02:44 AM: /opt/build/repo
11:02:44 AM: ​
11:02:44 AM: ❯ Config file
11:02:44 AM: No config file was defined: using default values.
11:02:44 AM: ​
11:02:44 AM: ❯ Context
11:02:44 AM: production
11:02:44 AM: ​
11:02:44 AM: ────────────────────────────────────────────────────────────────
11:02:44 AM: 1. Build command from Netlify app
11:02:44 AM: ────────────────────────────────────────────────────────────────
11:02:44 AM: ​
11:02:44 AM: $ npm run build
11:02:44 AM: npm ERR! code ENOENT
11:02:44 AM: npm ERR! syscall open
11:02:44 AM: npm ERR! path /opt/build/repo/package.json
11:02:44 AM: npm ERR! errno -2
11:02:44 AM: npm ERR! enoent ENOENT: no such file or directory, open ‘/opt/build/repo/package.json’
11:02:44 AM: npm ERR! enoent This is related to npm not being able to find a file.
11:02:44 AM: npm ERR! enoent
11:02:44 AM: npm ERR! A complete log of this run can be found in:
11:02:44 AM: npm ERR! /opt/buildhome/.npm/_logs/2022-03-06T11_02_44_388Z-debug-0.log
11:02:44 AM: ​
11:02:44 AM: ────────────────────────────────────────────────────────────────
11:02:44 AM: “build.command” failed
11:02:44 AM: ────────────────────────────────────────────────────────────────
11:02:44 AM: ​
11:02:44 AM: Error message
11:02:44 AM: Command failed with exit code 254: npm run build
11:02:44 AM: ​
11:02:44 AM: Error location
11:02:44 AM: In Build command from Netlify app:
11:02:44 AM: npm run build
11:02:44 AM: ​
11:02:44 AM: Resolved config
11:02:44 AM: build:
11:02:44 AM: base: /opt/build/repo
11:02:44 AM: command: npm run build
11:02:44 AM: commandOrigin: ui
11:02:44 AM: publish: /opt/build/repo/build
11:02:44 AM: publishOrigin: ui
11:02:45 AM: Caching artifacts
11:02:45 AM: Started saving build plugins
11:02:45 AM: Finished saving build plugins
11:02:45 AM: Started saving pip cache
11:02:45 AM: Finished saving pip cache
11:02:45 AM: Started saving emacs cask dependencies
11:02:45 AM: Finished saving emacs cask dependencies
11:02:45 AM: Started saving maven dependencies
11:02:45 AM: Finished saving maven dependencies
11:02:45 AM: Started saving boot dependencies
11:02:45 AM: Finished saving boot dependencies
11:02:45 AM: Started saving rust rustup cache
11:02:45 AM: Finished saving rust rustup cache
11:02:45 AM: Started saving go dependencies
11:02:45 AM: Finished saving go dependencies
11:02:47 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
11:02:47 AM: Creating deploy upload records
11:02:47 AM: Failing build: Failed to build site
11:02:47 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:02:48 AM: Finished processing build request in 16.957765026s

Hey @vasnas89

Check out this Support Guide for common issue when building.

You will also find numerous threads about the deployment of this particular NFT script by searching nft-minting-app-main in these forums.