Cloud Build: step exited with non-zero status Google Cloud / Firebase Origin: Platform & cloud OSI layer 7 · Application Last updated 4 Nov 2026

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.

Exact message you may see 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
Seen on: Google Cloud

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 dir or entrypoint
  • Cloud Build service account lacking a role (deploy, push)
  • Missing substitution variables

⚡ Quick fix

  1. Read the failing step's log output
  2. Run locally with cloud-build-local --config=cloudbuild.yaml .
  3. Add required roles to the Cloud Build service account

Detailed fix by platform

gcloud

  1. gcloud builds log BUILD_ID and gcloud builds describe BUILD_ID --format="value(status,failureInfo)"

Code examples

cloudbuild.yaml step

yaml
steps:
  - name: 'gcr.io/cloud-builders/npm'
    args: ['ci']
  - name: 'gcr.io/cloud-builders/npm'
    args: ['test']

How to diagnose

  1. Step — Which number?
  2. Log — First error?
  3. 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:

Where this error sits

Origin: Platform & cloud. Errors that are often confused with or caused by this one (click to open):

another operation is in progress — Error: UPGRADE FAILED: another operation (install/upgrade/rollback) is in progress (Kubernetes)another operation is …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 (Google Cloud / Firebase)API has not been used…Artifact Registry: Permission artifactregistry.repositories.uploadArtifacts denied — Docker push: denied: Permission "artifactregistry.repositories.uploadArtifacts" denied on resource "projects/p/locations/l/repositories/r" (Google Cloud / Firebase)Artifact Registry: Pe…BigQuery: Access Denied: Project: User does not have bigquery.jobs.create permission — BigQuery: Access Denied: Project my-project: User does not have bigquery.jobs.create permission in project my-project (Google Cloud / Firebase)BigQuery: Access Deni…Cloud Functions: Build failed — Cloud Functions: Build failed: function.js does not exist / npm install failed with exit code 1 (Cloud Build step) (Google Cloud / Firebase)Cloud Functions: Buil…Error 403: API has not been used in project (Terraform) — Terraform: Error: Error creating Network: googleapi: Error 403: Compute Engine API has not been used in project 123 before or it is disabled (Terraform)Error 403: API has no…ERROR: Job failed: exit code 1 — GitLab CI: ERROR: Job failed: exit code 1 (CI/CD)ERROR: Job failed: ex…Failed to find target with hash string — Failed to find target with hash string 'android-34' / Failed to install the following Android SDK packages as some licences have not been accepted (Android)Failed to find target…Cloud Bui…

Explore the map of this error Full error map →

🧠 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.