Build problem: command failed with exit code 1

Hi all! I’m trying to deploy a small React application hosted on GitHub and I’m currently unable to do so due to this error. The build log is as follows and I’ve changed no deploy settings yet on Netlify (nor On GitHub for that matter) so it’s all default. I’m being able to build locally and I get no warning messages when doing so. Any ideas on how to fix this? Thanks in advance.

8:53:55 AM: Build ready to start
8:53:57 AM: build-image version: d7b3dbfb0846505993c9a131894d1858074c90b4 (focal)
8:53:57 AM: build-image tag: v4.10.1
8:53:57 AM: buildbot version: 631f0363216079b7f038a5a332b842153439cb07
8:53:57 AM: Fetching cached dependencies
8:53:57 AM: Failed to fetch cache, continuing with build
8:53:57 AM: Starting to prepare the repo for build
8:53:57 AM: No cached dependencies found. Cloning fresh repo
8:53:57 AM: git clone https://github.com/LucianoInfanti/portfolio
8:53:58 AM: Preparing Git Reference refs/heads/master
8:53:58 AM: Parsing package.json dependencies
8:53:59 AM: Starting build script
8:53:59 AM: Installing dependencies
8:53:59 AM: Python version set to 2.7
8:53:59 AM: Downloading and installing node v16.17.0...
8:54:00 AM: Downloading https://nodejs.org/dist/v16.17.0/node-v16.17.0-linux-x64.tar.xz...
8:54:00 AM: Computing checksum with sha256sum
8:54:00 AM: Checksums matched!
8:54:02 AM: Now using node v16.17.0 (npm v8.15.0)
8:54:02 AM: Started restoring cached build plugins
8:54:02 AM: Finished restoring cached build plugins
8:54:02 AM: Attempting ruby version 2.7.2, read from environment
8:54:03 AM: Using ruby version 2.7.2
8:54:03 AM: Using PHP version 8.0
8:54:03 AM: No npm workspaces detected
8:54:03 AM: Started restoring cached node modules
8:54:03 AM: Finished restoring cached node modules
8:54:03 AM: Installing NPM modules using NPM version 8.15.0
8:54:04 AM: npm WARN config tmp This setting is no longer used.  npm stores temporary files in a special
8:54:04 AM: npm WARN config location in the cache, and they are managed by
8:54:04 AM: npm WARN config     [`cacache`](http://npm.im/cacache).
8:54:04 AM: npm WARN config tmp This setting is no longer used.  npm stores temporary files in a special
8:54:04 AM: npm WARN config location in the cache, and they are managed by
8:54:04 AM: npm WARN config     [`cacache`](http://npm.im/cacache).
8:54:15 AM: npm WARN deprecated source-map-url@0.4.1: See https://github.com/lydell/source-map-url#deprecated
8:54:16 AM: npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
8:54:16 AM: npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
8:54:17 AM: npm WARN deprecated source-map-resolve@0.5.3: See https://github.com/lydell/source-map-resolve#deprecated
8:54:17 AM: npm WARN deprecated statsd-client@0.4.7: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.
8:54:17 AM: npm WARN deprecated stable@0.1.8: Modern JS already guarantees Array#sort() is a stable sort, so this library is deprecated. See the compatibility table on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#browser_compatibility
8:54:18 AM: npm WARN deprecated source-map-resolve@0.6.0: See https://github.com/lydell/source-map-resolve#deprecated
8:54:18 AM: npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
8:54:22 AM: npm WARN deprecated svgo@1.3.2: This SVGO version is no longer supported. Upgrade to v2.x.x.
8:54:24 AM: npm WARN deprecated querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
8:54:24 AM: npm WARN deprecated request@2.88.0: request has been deprecated, see https://github.com/request/request/issues/3142
8:54:25 AM: npm WARN deprecated har-validator@5.1.5: this library is no longer supported
8:54:31 AM: npm WARN deprecated core-js@2.6.12: core-js@<3.4 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.
8:54:35 AM: added 3462 packages, and audited 3463 packages in 31s
8:54:35 AM: 306 packages are looking for funding
8:54:35 AM:   run `npm fund` for details
8:54:35 AM: 24 vulnerabilities (11 moderate, 13 high)
8:54:35 AM: To address issues that do not require attention, run:
8:54:35 AM:   npm audit fix
8:54:35 AM: To address all issues (including breaking changes), run:
8:54:35 AM:   npm audit fix --force
8:54:35 AM: Run `npm audit` for details.
8:54:35 AM: NPM modules installed
8:54:35 AM: npm WARN config tmp This setting is no longer used.  npm stores temporary files in a special
8:54:35 AM: npm WARN config location in the cache, and they are managed by
8:54:35 AM: npm WARN config     [`cacache`](http://npm.im/cacache).
8:54:35 AM: Started restoring cached go cache
8:54:35 AM: Finished restoring cached go cache
8:54:35 AM: Installing Go version 1.17 (requested 1.17)
8:54:40 AM: unset GOOS;
8:54:40 AM: unset GOARCH;
8:54:40 AM: export GOROOT='/opt/buildhome/.gimme/versions/go1.17.linux.amd64';
8:54:40 AM: export PATH="/opt/buildhome/.gimme/versions/go1.17.linux.amd64/bin:${PATH}";
8:54:40 AM: go version >&2;
8:54:40 AM: export GIMME_ENV="/opt/buildhome/.gimme/env/go1.17.linux.amd64.env"
8:54:40 AM: go version go1.17 linux/amd64
8:54:40 AM: Installing missing commands
8:54:40 AM: Verify run directory
8:54:41 AM: ​
8:54:41 AM: ────────────────────────────────────────────────────────────────
8:54:41 AM:   Netlify Build                                                 
8:54:41 AM: ────────────────────────────────────────────────────────────────
8:54:41 AM: ​
8:54:41 AM: ❯ Version
8:54:41 AM:   @netlify/build 27.18.2
8:54:41 AM: ​
8:54:41 AM: ❯ Flags
8:54:41 AM:   baseRelDir: true
8:54:41 AM:   buildId: 632858531ad2820009536f3e
8:54:41 AM:   deployId: 632858531ad2820009536f40
8:54:41 AM: ​
8:54:41 AM: ❯ Current directory
8:54:41 AM:   /opt/build/repo
8:54:41 AM: ​
8:54:41 AM: ❯ Config file
8:54:41 AM:   No config file was defined: using default values.
8:54:41 AM: ​
8:54:41 AM: ❯ Context
8:54:41 AM:   production
8:54:41 AM: ​
8:54:41 AM: ────────────────────────────────────────────────────────────────
8:54:41 AM:   1. Build command from Netlify app                             
8:54:41 AM: ────────────────────────────────────────────────────────────────
8:54:41 AM: ​
8:54:41 AM: $ npm run build
8:54:41 AM: npm WARN config tmp This setting is no longer used.  npm stores temporary files in a special
8:54:41 AM: npm WARN config location in the cache, and they are managed by
8:54:41 AM: npm WARN config     [`cacache`](http://npm.im/cacache).
8:54:41 AM: > blog@0.1.0 build
8:54:41 AM: > react-scripts build
8:54:42 AM: Creating an optimized production build...
8:54:53 AM: 
8:54:53 AM: Treating warnings as errors because process.env.CI = true.
8:54:53 AM: Most CI servers set it automatically.
8:54:53 AM: 
8:54:53 AM: Failed to compile.
8:54:53 AM: 
8:54:53 AM: [eslint]
8:54:53 AM: src/pages/blog/article2/index.jsx
8:54:53 AM:   Line 3:8:  'Code' is defined but never used  no-unused-vars
8:54:53 AM: src/routes/index.js
8:54:53 AM:   Line 18:1:  Block is redundant  no-lone-blocks
8:54:53 AM: ​
8:54:53 AM: ────────────────────────────────────────────────────────────────
8:54:53 AM:   "build.command" failed                                        
8:54:53 AM: ────────────────────────────────────────────────────────────────
8:54:53 AM: ​
8:54:53 AM:   Error message
8:54:53 AM:   Command failed with exit code 1: npm run build (https://ntl.fyi/exit-code-1)
8:54:53 AM: ​
8:54:53 AM:   Error location
8:54:53 AM:   In Build command from Netlify app:
8:54:53 AM:   npm run build
8:54:53 AM: ​
8:54:53 AM:   Resolved config
8:54:53 AM:   build:
8:54:53 AM:     command: npm run build
8:54:53 AM:     commandOrigin: ui
8:54:53 AM:     publish: /opt/build/repo/build
8:54:53 AM:     publishOrigin: ui
8:54:53 AM: Caching artifacts
8:54:53 AM: Started saving node modules
8:54:53 AM: Finished saving node modules
8:54:53 AM: Started saving build plugins
8:54:53 AM: Finished saving build plugins
8:54:53 AM: Started saving pip cache
8:54:53 AM: Finished saving pip cache
8:54:53 AM: Started saving emacs cask dependencies
8:54:53 AM: Finished saving emacs cask dependencies
8:54:53 AM: Started saving maven dependencies
8:54:53 AM: Finished saving maven dependencies
8:54:53 AM: Started saving boot dependencies
8:54:53 AM: Finished saving boot dependencies
8:54:53 AM: Started saving rust rustup cache
8:54:53 AM: Finished saving rust rustup cache
8:54:53 AM: Started saving go dependencies
8:54:53 AM: Finished saving go dependencies
8:54:54 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
8:54:54 AM: Creating deploy upload records
8:54:54 AM: Failing build: Failed to build site
8:54:54 AM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
8:54:54 AM: Finished processing build request in 57.176962465s

Howdy @Lucianoinfanti !

Have you read our build debugging guide? [Support Guide] Debugging Netlify site builds

That’s where all build debugging should start. Please bookmark it as it will be our (first) answer to later questions about building, too :slight_smile:

But, I think in your case I see the problem:

8:54:53 AM: Treating warnings as errors because process.env.CI = true.
8:54:53 AM: Most CI servers set it automatically.

This means “if your code issues a warning, we’ll fail the build”. Your code immediately issues a warning:

8:54:53 AM: [eslint]
8:54:53 AM: src/pages/blog/article2/index.jsx
8:54:53 AM:   Line 3:8:  'Code' is defined but never used  no-unused-vars
8:54:53 AM: src/routes/index.js
8:54:53 AM:   Line 18:1:  Block is redundant  no-lone-blocks
8:54:53 AM: ​

…so we fail the build as promised.

You can follow this article’s suggestions to change that behavior: New CI=true build configuration, "Treating warnings as errors because process.env.CI = true"

1 Like