Cloud Build: ERROR: build step 2 "gcr.io/cloud-builders/npm" failed: step exited with non-zero status: 1
One step of the Cloud Build pipeline returned a non-zero exit code, so the whole build failed.
build step failed: step exited with non-zero status: 1ERROR: build step 2 failed: step exited with non-zero statusStep #2 - failed: step exited with non-zero statusBUILD FAILURE: Build step failure: build step failedERROR: failed to build: exit status 1 Cloud Build Meaning
Open the build log and read the output of that step (the failing command is printed above). Reproduce locally in the same builder image or with cloud-build-local. Typical issues: failing tests, missing files because of .gcloudignore, wrong working directory (dir:), or lack of permissions for deploy steps.
Common causes
- Tests/build commands failing in the step
- Files excluded by .gcloudignore/.gitignore
- Wrong
dirorentrypoint - Cloud Build service account lacking a role (deploy, push)
- Missing substitution variables
⚡ Quick fix
- Read the failing step's log output
- Run locally with
cloud-build-local --config=cloudbuild.yaml . - Add required roles to the Cloud Build service account
Detailed fix by platform
gcloud
gcloud builds log BUILD_IDandgcloud builds describe BUILD_ID --format="value(status,failureInfo)"
Code examples
cloudbuild.yaml step
steps:
- name: 'gcr.io/cloud-builders/npm'
args: ['ci']
- name: 'gcr.io/cloud-builders/npm'
args: ['test']How to diagnose
- Step — Which number?
- Log — First error?
- Rights — Build SA roles?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- another operation is in progress Error: UPGRADE FAILED: another operation (install/upgrade/rollback) is in progress
- API has not been used in project before or it is disabled Google Cloud: 403 SERVICE_DISABLED — Cloud Resource Manager API has not been used in project 123456 before or it is disabled. Enable it by visiting
- Artifact Registry: Permission artifactregistry.repositories.uploadArtifacts denied Docker push: denied: Permission "artifactregistry.repositories.uploadArtifacts" denied on resource "projects/p/locations/l/repositories/r"
Most viewed in Google Cloud / Firebase
- Missing or insufficient permissions Firestore: FirebaseError: [code=permission-denied]: Missing or insufficient permissions
- Container failed to start Cloud Run: The user-provided container failed to start and listen on the port defined provided by the PORT=8080 environment variable
- Could not load the default credentials Google Cloud: Error: Could not load the default credentials. Browse to https://cloud.google.com/docs/authentication/getting-started
Other ways to find it
Where this error sits
Origin: Platform & cloud. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 4 Nov 2026