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

My first time trying to deploy a website using parcel to build, don’t know why it’s giving me a user error, please help!

Deploy log is given below:

type or paste cod11:49:13 PM: Build ready to start
11:49:15 PM: build-image version: d7b3dbfb0846505993c9a131894d1858074c90b4 (focal)
11:49:15 PM: build-image tag: v4.10.1
11:49:15 PM: buildbot version: f4df34fdee5e467fb0a8a2f62e3840ffaba0a9bc
11:49:15 PM: Building without cache
11:49:15 PM: Starting to prepare the repo for build
11:49:16 PM: No cached dependencies found. Cloning fresh repo
11:49:16 PM: git clone https://github.com/michael-j-rubenstein/website-tutorial
11:49:16 PM: Preparing Git Reference refs/heads/main
11:49:17 PM: Parsing package.json dependencies
11:49:17 PM: 
​
❯ Initial build environment
baseRelDir: true
branch: main
context: production
cwd: /opt/build/repo
featureFlags: []
mode: buildbot
repositoryRoot: /opt/build/repo
siteId: 0af13ada-84b0-430a-aa50-414f5c35a99a
​
❯ UI build settings
baseRelDir: true
build:
  command: parcel build index.html
  environment:
    - NETLIFY_BUILD_DEBUG
  publish: dist
​
❯ Resolved build environment
branch: main
buildDir: /opt/build/repo
context: production
env: []
​
❯ Resolved config
build:
  command: parcel build index.html
  commandOrigin: ui
  environment:
    - NETLIFY_BUILD_DEBUG
  publish: /opt/build/repo/dist
  publishOrigin: ui

11:49:17 PM: Starting build script
11:49:17 PM: Installing dependencies
11:49:17 PM: Python version set to 2.7
11:49:18 PM: v16.16.0 is already installed.
11:49:18 PM: Now using node v16.16.0 (npm v8.11.0)
11:49:18 PM: Started restoring cached build plugins
11:49:18 PM: Finished restoring cached build plugins
11:49:18 PM: Attempting ruby version 2.7.2, read from environment
11:49:19 PM: Using ruby version 2.7.2
11:49:19 PM: Using PHP version 8.0
11:49:19 PM: No npm workspaces detected
11:49:19 PM: Started restoring cached node modules
11:49:19 PM: Finished restoring cached node modules
11:49:19 PM: Installing NPM modules using NPM version 8.11.0
11:49:20 PM: npm WARN config tmp This setting is no longer used.  npm stores temporary files in a special
11:49:20 PM: npm WARN config location in the cache, and they are managed by
11:49:20 PM: npm WARN config     [`cacache`](http://npm.im/cacache).
11:49:20 PM: npm WARN config tmp This setting is no longer used.  npm stores temporary files in a special
11:49:20 PM: npm WARN config location in the cache, and they are managed by
11:49:20 PM: npm WARN config     [`cacache`](http://npm.im/cacache).
11:49:23 PM: npm WARN deprecated source-map-url@0.4.1: See https://github.com/lydell/source-map-url#deprecated
11:49:23 PM: npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
11:49:23 PM: npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
11:49:23 PM: npm WARN deprecated source-map-resolve@0.5.3: See https://github.com/lydell/source-map-resolve#deprecated
11:49:24 PM: npm WARN deprecated request-promise-native@1.0.9: request-promise-native has been deprecated because it extends the now deprecated request package, see https://github.com/request/request/issues/3142
11:49:24 PM: 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
11:49:24 PM: 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.
11:49:24 PM: npm WARN deprecated querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
11:49:25 PM: npm WARN deprecated har-validator@5.1.5: this library is no longer supported
11:49:26 PM: npm WARN deprecated chokidar@2.1.8: Chokidar 2 does not receive security updates since 2019. Upgrade to chokidar 3 with 15x fewer dependencies
11:49:26 PM: npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
11:49:28 PM: npm WARN deprecated svgo@1.3.2: This SVGO version is no longer supported. Upgrade to v2.x.x.
11:49:29 PM: npm WARN deprecated parcel-bundler@1.12.4: Parcel v1 is no longer maintained. Please migrate to v2, which is published under the 'parcel' package. See https://v2.parceljs.org/getting-started/migration for details.
11:49:29 PM: npm WARN deprecated core-js@2.6.12: core-js@<3.23.3 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. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.
11:49:30 PM: added 801 packages, and audited 802 packages in 10s
11:49:30 PM: 59 packages are looking for funding
11:49:30 PM:   run `npm fund` for details
11:49:30 PM: 23 vulnerabilities (9 moderate, 14 high)
11:49:30 PM: To address issues that do not require attention, run:
11:49:30 PM:   npm audit fix
11:49:30 PM: To address all issues (including breaking changes), run:
11:49:30 PM:   npm audit fix --force
11:49:30 PM: Run `npm audit` for details.
11:49:30 PM: NPM modules installed
11:49:30 PM: npm WARN config tmp This setting is no longer used.  npm stores temporary files in a special
11:49:30 PM: npm WARN config location in the cache, and they are managed by
11:49:30 PM: npm WARN config     [`cacache`](http://npm.im/cacache).
11:49:30 PM: Started restoring cached go cache
11:49:30 PM: Finished restoring cached go cache
11:49:30 PM: Installing Go version 1.17 (requested 1.17)
11:49:35 PM: unset GOOS;
11:49:35 PM: unset GOARCH;
11:49:35 PM: export GOROOT='/opt/buildhome/.gimme/versions/go1.17.linux.amd64';
11:49:35 PM: export PATH="/opt/buildhome/.gimme/versions/go1.17.linux.amd64/bin:${PATH}";
11:49:35 PM: go version >&2;
11:49:35 PM: export GIMME_ENV="/opt/buildhome/.gimme/env/go1.17.linux.amd64.env"
11:49:35 PM: go version go1.17 linux/amd64
11:49:35 PM: Installing missing commands
11:49:35 PM: Verify run directory
11:49:36 PM: ​
11:49:36 PM: ────────────────────────────────────────────────────────────────
11:49:36 PM:   Netlify Build                                                 
11:49:36 PM: ────────────────────────────────────────────────────────────────
11:49:36 PM: ​
11:49:36 PM: ❯ Version
11:49:36 PM:   @netlify/build 27.9.1
11:49:36 PM: ​
11:49:36 PM: ❯ Flags
11:49:36 PM:   apiHost: api.netlify.com
11:49:36 PM:   baseRelDir: true
11:49:36 PM:   branch: main
11:49:36 PM:   buildId: 62f47c3917e12864a8fad3c3
11:49:36 PM:   buildbotServerSocket: /tmp/netlify-buildbot-socket
11:49:36 PM:   cacheDir: /opt/build/cache
11:49:36 PM:   cachedConfigPath: /tmp/netlify_config.json
11:49:36 PM:   context: production
11:49:36 PM:   cwd: /opt/build/repo
11:49:36 PM:   deployId: 62f47c3917e12864a8fad3c5
11:49:36 PM:   edgeFunctionsDistDir: /tmp/edge-62f47c3917e12864a8fad3c5
11:49:36 PM:   featureFlags:
11:49:36 PM:     - edge_functions_cache_cli
11:49:36 PM:     - edge_functions_produce_eszip
11:49:36 PM:   framework: parcel
11:49:36 PM:   functionsDistDir: /tmp/zisi-62f47c3917e12864a8fad3c5
11:49:36 PM:   mode: buildbot
11:49:36 PM:   nodePath: /opt/buildhome/.nvm/versions/node/v16.16.0/bin/node
11:49:36 PM:   repositoryRoot: /opt/build/repo
11:49:36 PM:   saveConfig: true
11:49:36 PM:   sendStatus: true
11:49:36 PM:   siteId: 0af13ada-84b0-430a-aa50-414f5c35a99a
11:49:36 PM:   statsd:
11:49:36 PM:     host: 10.65.137.241
11:49:36 PM:     port: 8125
11:49:36 PM:   systemLogFile: 3
11:49:36 PM:   testOpts:
11:49:36 PM:     silentLingeringProcesses: ''
11:49:36 PM: ​
11:49:36 PM: ❯ Current directory
11:49:36 PM:   /opt/build/repo
11:49:36 PM: ​
11:49:36 PM: ❯ Config file
11:49:36 PM:   No config file was defined: using default values.
11:49:36 PM: ​
11:49:36 PM: ❯ Resolved config
11:49:36 PM:   build:
11:49:36 PM:     command: parcel build index.html
11:49:36 PM:     commandOrigin: ui
11:49:36 PM:     environment:
11:49:36 PM:       - NETLIFY_BUILD_DEBUG
11:49:36 PM:     publish: /opt/build/repo/dist
11:49:36 PM:     publishOrigin: ui
11:49:36 PM: ​
11:49:36 PM: ❯ Context
11:49:36 PM:   production
11:49:36 PM: ​
11:49:36 PM: ────────────────────────────────────────────────────────────────
11:49:36 PM:   1. Build command from Netlify app                             
11:49:36 PM: ────────────────────────────────────────────────────────────────
11:49:36 PM: ​
11:49:36 PM: $ parcel build index.html
11:49:37 PM: 🚨  /opt/build/repo/images/logo.svg: Invalid Version: undefined
11:49:37 PM:     at new SemVer (/opt/build/repo/node_modules/@babel/preset-env/node_modules/semver/semver.js:314:11)
11:49:37 PM:     at compare (/opt/build/repo/node_modules/@babel/preset-env/node_modules/semver/semver.js:647:10)
11:49:37 PM:     at Function.lt (/opt/build/repo/node_modules/@babel/preset-env/node_modules/semver/semver.js:688:10)
11:49:37 PM:     at /opt/build/repo/node_modules/@babel/preset-env/lib/index.js:275:15
11:49:37 PM:     at Object.default (/opt/build/repo/node_modules/@babel/helper-plugin-utils/lib/index.js:23:12)
11:49:37 PM:     at getEnvPlugins (/opt/build/repo/node_modules/parcel-bundler/src/transforms/babel/env.js:62:34)
11:49:37 PM:     at getEnvConfig (/opt/build/repo/node_modules/parcel-bundler/src/transforms/babel/env.js:12:25)
11:49:37 PM:     at async getBabelConfig (/opt/build/repo/node_modules/parcel-bundler/src/transforms/babel/config.js:32:19)
11:49:37 PM:     at async babelTransform (/opt/build/repo/node_modules/parcel-bundler/src/transforms/babel/transform.js:6:16)
11:49:37 PM:     at async JSAsset.pretransform (/opt/build/repo/node_modules/parcel-bundler/src/assets/JSAsset.js:83:5)
11:49:38 PM: ​
11:49:38 PM: ────────────────────────────────────────────────────────────────
11:49:38 PM:   "build.command" failed                                        
11:49:38 PM: ────────────────────────────────────────────────────────────────
11:49:38 PM: ​
11:49:38 PM:   Error message
11:49:38 PM:   Command failed with exit code 1: parcel build index.html (https://ntl.fyi/exit-code-1)
11:49:38 PM: ​
11:49:38 PM:   Error location
11:49:38 PM:   In Build command from Netlify app:
11:49:38 PM:   parcel build index.html
11:49:38 PM: ​
11:49:38 PM:   Resolved config
11:49:38 PM:   build:
11:49:38 PM:     command: parcel build index.html
11:49:38 PM:     commandOrigin: ui
11:49:38 PM:     environment:
11:49:38 PM:       - NETLIFY_BUILD_DEBUG
11:49:38 PM:     publish: /opt/build/repo/dist
11:49:38 PM:     publishOrigin: ui
11:49:39 PM: Caching artifacts
11:49:39 PM: Started saving node modules
11:49:39 PM: Finished saving node modules
11:49:39 PM: Started saving build plugins
11:49:39 PM: Finished saving build plugins
11:49:39 PM: Started saving pip cache
11:49:39 PM: Finished saving pip cache
11:49:39 PM: Started saving emacs cask dependencies
11:49:39 PM: Finished saving emacs cask dependencies
11:49:39 PM: Started saving maven dependencies
11:49:39 PM: Finished saving maven dependencies
11:49:39 PM: Started saving boot dependencies
11:49:39 PM: Finished saving boot dependencies
11:49:39 PM: Started saving rust rustup cache
11:49:39 PM: Finished saving rust rustup cache
11:49:39 PM: Started saving go dependencies
11:49:39 PM: Finished saving go dependencies
11:49:40 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
11:49:40 PM: Creating deploy upload records
11:49:40 PM: Failing build: Failed to build site
11:49:40 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
11:49:40 PM: Finished processing build request in 24.962283961se here

Hey @michael-j-rubenstein

Seems there is an issue with an SVG file. Without seeing/testing myself I can only guess, but you might need to disable SVG minification as per this Parcel documentation.

Hey @coelmay

Sorry I was busy with work and hadn’t had a chance to respond.

I tried adding the htmlnanrc file to not minify svg elements but it still shows the same error message.

Without a public repository to test, it’s a little hard to offer further advice.

1 Like

Just changed it to public! you can find it here: GitHub - michael-j-rubenstein/website-tutorial

There is another thread regarding this issue. The simple fix is to downgrade parcel to 1.12.3 by running npm i -D parcel-bundler@1.12.3. This worked for me. Other options are to upgrade to parcel v2 though this may introduce other bugs (but also add more features perhaps.)

If you want to pin the version to avoid updating to 1.12.4 again (inadvertently) run npm i -DE parcel-bundler@1.12.3 which will pin this version.

2 Likes

Thank you so much!!! I downgraded to version 1.12.3 and it worked! Thank you!!!

2 Likes

Thanks for the excellent guidance, @coelmay. Glad everything is working now, @michael-j-rubenstein!!