I have an Angular 17 app which I want to deploy.
It’s always throwing the same weird error and not mentioning anything specific other than “An unexpected error occurred: [object Object]”, but it mentions 2 different exit codes:
Failed during stage “building site”: Build script returned non-zero exit code: 2
and then
Command failed with exit code 1: npm run build (Search results for '"non-zero exit code: 1"' - Netlify Support Forums)
But it seems like something from the build of the netlify app.
What am I missing?
I already tried with and without the Angular runtime in the deploy settings, but it didn’t change a single thing while doing so.
In my local environment it builds perfectly fine even if I clone from scratch my repo, npm install and then npm run build.
Below the details:
Site name: storied-sprinkles-1b4534
Logs:
11:43:22 AM: build-image version: 3ffff9df3d5419545acc1b673a54de348174406d (focal)
11:43:22 AM: buildbot version: 06bd328e5eb3b6956f9c6602486ecccce8b861a0
11:43:22 AM: Building without cache
11:43:22 AM: Starting to prepare the repo for build
11:43:22 AM: No cached dependencies found. Cloning fresh repo
11:43:22 AM: git clone --filter=blob:none https://github.com/CesarD/decapng
11:43:22 AM: Preparing Git Reference refs/heads/master
11:43:24 AM: Starting to install dependencies
11:43:24 AM: Python version set to 3.8
11:43:24 AM: Attempting Ruby version 2.7.2, read from environment
11:43:25 AM: Using Ruby version 2.7.2
11:43:25 AM: Started restoring cached go cache
11:43:25 AM: Finished restoring cached go cache
11:43:26 AM: go version go1.19.13 linux/amd64
11:43:27 AM: Using PHP version 8.0
11:43:28 AM: Downloading and installing node v18.19.0…
11:43:28 AM: Downloading https://nodejs.org/dist/v18.19.0/node-v18.19.0-linux-x64.tar.xz…
11:43:28 AM: Computing checksum with sha256sum
11:43:28 AM: Checksums matched!
11:43:30 AM: Now using node v18.19.0 (npm v10.2.3)
11:43:30 AM: Enabling Node.js Corepack
11:43:30 AM: Started restoring cached build plugins
11:43:30 AM: Finished restoring cached build plugins
11:43:30 AM: Started restoring cached corepack dependencies
11:43:30 AM: Finished restoring cached corepack dependencies
11:43:30 AM: No npm workspaces detected
11:43:30 AM: Started restoring cached node modules
11:43:30 AM: Finished restoring cached node modules
11:43:30 AM: Installing npm packages using npm version 10.2.3
11:43:41 AM: npm WARN deprecated abab@2.0.6: Use your platform"s native atob() and btoa() methods instead
11:43:41 AM: added 989 packages, and audited 990 packages in 10s
11:43:41 AM: 119 packages are looking for funding
11:43:41 AM: run npm fund
for details
11:43:41 AM: 4 moderate severity vulnerabilities
11:43:41 AM: To address all issues (including breaking changes), run:
11:43:41 AM: npm audit fix --force
11:43:41 AM: Run npm audit
for details.
11:43:41 AM: npm packages installed
11:43:42 AM: Successfully installed dependencies
11:43:42 AM: Starting build script
11:43:42 AM: Detected 1 framework(s)
11:43:42 AM: “angular” at version “17.0.6”
11:43:42 AM: Section completed: initializing
11:43:44 AM:
11:43:44 AM: Netlify Build
11:43:44 AM: ────────────────────────────────────────────────────────────────
11:43:44 AM:
11:43:44 AM: ❯ Version
11:43:44 AM: @netlify/build 29.31.0
11:43:44 AM:
11:43:44 AM: ❯ Flags
11:43:44 AM: baseRelDir: true
11:43:44 AM: buildId: 65783948cf0a0144087cfd23
11:43:44 AM: deployId: 65783948cf0a0144087cfd25
11:43:44 AM:
11:43:44 AM: ❯ Current directory
11:43:44 AM: /opt/build/repo
11:43:44 AM:
11:43:44 AM: ❯ Config file
11:43:44 AM: No config file was defined: using default values.
11:43:44 AM:
11:43:44 AM: ❯ Context
11:43:44 AM: production
11:43:44 AM:
11:43:44 AM: Build command from Netlify app
11:43:44 AM: ────────────────────────────────────────────────────────────────
11:43:44 AM:
11:43:44 AM: $ npm run build
11:43:44 AM: > decap-ng@0.0.0 build
11:43:44 AM: > ng build
11:43:45 AM: - Building…
11:43:55 AM: Failed during stage “building site”: Build script returned non-zero exit code: 2
11:43:54 AM: An unexpected error occurred: [object Object]
11:43:54 AM:
11:43:54 AM: “build.command” failed
11:43:54 AM: ────────────────────────────────────────────────────────────────
11:43:54 AM:
11:43:54 AM: Error message
11:43:54 AM: Command failed with exit code 1: npm run build (Search results for '"non-zero exit code: 1"' - Netlify Support Forums)
11:43:54 AM:
11:43:54 AM: Error location
11:43:54 AM: In Build command from Netlify app:
11:43:54 AM: npm run build
11:43:54 AM:
11:43:54 AM: Resolved config
11:43:54 AM: build:
11:43:54 AM: command: npm run build
11:43:54 AM: commandOrigin: ui
11:43:54 AM: publish: /opt/build/repo/dist/decap-ng/browser
11:43:54 AM: publishOrigin: ui
11:43:55 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
11:43:55 AM: Failing build: Failed to build site
11:43:55 AM: Finished processing build request in 33.616s
Any help will be much appreciated. Thanks.