Home
Support Forums

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 Recat Application !
6:49:42 PM: Build ready to start
6:49:44 PM: build-image version: 2cee85eb7f808bf3b6e87378c5307f9411f0a332
6:49:44 PM: build-image tag: v3.8.0
6:49:44 PM: buildbot version: 02abb8b68968c22860647fd09d700bee67acb65f
6:49:45 PM: Fetching cached dependencies
6:49:45 PM: Failed to fetch cache, continuing with build
6:49:45 PM: Starting to prepare the repo for build
6:49:45 PM: No cached dependencies found. Cloning fresh repo
6:49:45 PM: git clone GitHub - Zaina-coder/newapp
6:49:46 PM: Preparing Git Reference refs/heads/master
6:49:46 PM: Parsing package.json dependencies
6:49:47 PM: Starting build script
6:49:47 PM: Installing dependencies
6:49:47 PM: Python version set to 2.7
6:49:48 PM: v12.18.0 is already installed.
6:49:48 PM: Now using node v12.18.0 (npm v6.14.4)
6:49:49 PM: Started restoring cached build plugins
6:49:49 PM: Finished restoring cached build plugins
6:49:49 PM: Attempting ruby version 2.7.2, read from environment
6:49:50 PM: Using ruby version 2.7.2
6:49:50 PM: Using PHP version 5.6
6:49:50 PM: Started restoring cached node modules
6:49:50 PM: Finished restoring cached node modules
6:49:50 PM: Installing NPM modules using NPM version 6.14.4
6:50:21 PM: npm WARN read-shrinkwrap This version of npm is compatible with lockfileVersion@1, but package-lock.json was generated for lockfileVersion@2. I’ll try to do my best with it!
6:50:21 PM: > core-js@2.6.12 postinstall /opt/build/repo/node_modules/babel-runtime/node_modules/core-js
6:50:21 PM: > node -e “try{require(’./postinstall’)}catch(e){}”
6:50:21 PM: > core-js@3.15.0 postinstall /opt/build/repo/node_modules/core-js
6:50:21 PM: > node -e “try{require(’./postinstall’)}catch(e){}”
6:50:21 PM: > core-js-pure@3.15.0 postinstall /opt/build/repo/node_modules/core-js-pure
6:50:21 PM: > node -e “try{require(’./postinstall’)}catch(e){}”
6:50:22 PM: > ejs@2.7.4 postinstall /opt/build/repo/node_modules/ejs
6:50:22 PM: > node ./postinstall.js
6:50:25 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/webpack-dev-server/node_modules/fsevents):
6:50:25 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {“os”:“darwin”,“arch”:“any”} (current: {“os”:“linux”,“arch”:“x64”})
6:50:25 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/watchpack-chokidar2/node_modules/fsevents):
6:50:25 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {“os”:“darwin”,“arch”:“any”} (current: {“os”:“linux”,“arch”:“x64”})
6:50:25 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.3.2 (node_modules/fsevents):
6:50:25 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {“os”:“darwin”,“arch”:“any”} (current: {“os”:“linux”,“arch”:“x64”})
6:50:25 PM: added 1823 packages from 740 contributors and audited 1829 packages in 33.562s
6:50:27 PM: 146 packages are looking for funding
6:50:27 PM: run npm fund for details
6:50:27 PM: found 6 vulnerabilities (4 moderate, 2 high)
6:50:27 PM: run npm audit fix to fix them, or npm audit for details
6:50:27 PM: NPM modules installed
6:50:27 PM: Started restoring cached go cache
6:50:27 PM: Finished restoring cached go cache
6:50:27 PM: go version go1.14.4 linux/amd64
6:50:27 PM: go version go1.14.4 linux/amd64
6:50:27 PM: Installing missing commands
6:50:27 PM: Verify run directory
6:50:28 PM: ​
6:50:28 PM: ────────────────────────────────────────────────────────────────
6:50:28 PM: Netlify Build
6:50:28 PM: ────────────────────────────────────────────────────────────────
6:50:28 PM: ​
6:50:28 PM: ❯ Version
6:50:28 PM: @netlify/build 15.2.2
6:50:28 PM: ​
6:50:28 PM: ❯ Flags
6:50:28 PM: deployId: 60e659b6b6fbed45bebfef35
6:50:28 PM: ​
6:50:28 PM: ❯ Current directory
6:50:28 PM: /opt/build/repo
6:50:28 PM: ​
6:50:28 PM: ❯ Config file
6:50:28 PM: No config file was defined: using default values.
6:50:28 PM: ​
6:50:28 PM: ❯ Context
6:50:28 PM: production
6:50:28 PM: ​
6:50:28 PM: ────────────────────────────────────────────────────────────────
6:50:28 PM: 1. Build command from Netlify app
6:50:28 PM: ────────────────────────────────────────────────────────────────
6:50:28 PM: ​
6:50:28 PM: $ npm run build
6:50:29 PM: > newapp@0.1.0 build /opt/build/repo
6:50:29 PM: > react-scripts build
6:50:31 PM: Creating an optimized production build…
6:50:46 PM:
6:50:46 PM: Treating warnings as errors because process.env.CI = true.
6:50:46 PM: Most CI servers set it automatically.
6:50:46 PM:
6:50:46 PM: Failed to compile.
6:50:46 PM:
6:50:46 PM: src/App.js
6:50:46 PM: Line 17:8: Using target="_blank" without rel=“noreferrer” is a security risk: see HTML Standard react/jsx-no-target-blank
6:50:46 PM: npm ERR! code ELIFECYCLE
6:50:46 PM: npm ERR! errno 1
6:50:46 PM: npm ERR! newapp@0.1.0 build: react-scripts build
6:50:46 PM: npm ERR! Exit status 1
6:50:46 PM: npm ERR!
6:50:46 PM: npm ERR! Failed at the newapp@0.1.0 build script.
6:50:46 PM: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
6:50:46 PM: npm ERR! A complete log of this run can be found in:
6:50:46 PM: npm ERR! /opt/buildhome/.npm/_logs/2021-07-08T01_50_46_552Z-debug.log
6:50:46 PM: ​
6:50:46 PM: ────────────────────────────────────────────────────────────────
6:50:46 PM: “build.command” failed
6:50:46 PM: ────────────────────────────────────────────────────────────────
6:50:46 PM: ​
6:50:46 PM: Error message
6:50:46 PM: Command failed with exit code 1: npm run build
6:50:46 PM: ​
6:50:46 PM: Error location
6:50:46 PM: In Build command from Netlify app:
6:50:46 PM: npm run build
6:50:46 PM: ​
6:50:46 PM: Resolved config
6:50:46 PM: build:
6:50:46 PM: command: npm run build
6:50:46 PM: commandOrigin: ui
6:50:46 PM: publish: /opt/build/repo/build
6:50:46 PM: publishOrigin: ui
6:50:46 PM: functions:
6:50:46 PM: ‘*’: {}
6:50:46 PM: Caching artifacts
6:50:46 PM: Started saving node modules
6:50:46 PM: Finished saving node modules
6:50:46 PM: Started saving build plugins
6:50:46 PM: Finished saving build plugins
6:50:46 PM: Started saving pip cache
6:50:47 PM: Finished saving pip cache
6:50:47 PM: Started saving emacs cask dependencies
6:50:47 PM: Finished saving emacs cask dependencies
6:50:47 PM: Started saving maven dependencies
6:50:47 PM: Finished saving maven dependencies
6:50:47 PM: Started saving boot dependencies
6:50:47 PM: Finished saving boot dependencies
6:50:47 PM: Started saving rust rustup cache
6:50:47 PM: Finished saving rust rustup cache
6:50:47 PM: Started saving go dependencies
6:50:47 PM: Finished saving go dependencies
6:50:49 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
6:50:50 PM: Creating deploy upload records
6:50:50 PM: Failing build: Failed to build site
6:50:50 PM: Failed during stage ‘building site’: Build script returned non-zero exit code: 2
6:50:50 PM: Finished processing build request in 1m5.275265809s

Hi @Zaina_coder

This line in src/App.js is the culprit

Add rel="noreferrer" to the URL and is should work (here’s the deploy I made with your code https://friendly-engelbart-9c418a.netlify.app/)

1 Like

@Zaina_coder what @coelmay suggested above is correct. However, if you wish to ignore it, you could change your build command to CI= npm run build.

1 Like

Thank you so much it worked :slight_smile: