Cloud Functions: Build failed Google Cloud / Firebase Origin: Platform & cloud Last updated 4 Nov 2026

Cloud Functions: Build failed: function.js does not exist / npm install failed with exit code 1 (Cloud Build step)

The deployment's build step (Cloud Build) failed, so no new function version was created.

Exact message you may see Build failed: function.js does not existCloud Functions Build failedBuild failed: npm install failed with exit code 1ERROR: (gcloud.functions.deploy) OperationError: code=3, message=Build failedBuild failed with status: FAILURE and message
Seen on: Google Cloud

Meaning

Open the build logs link from the error. Frequent causes: a failing npm install/pip install, missing package.json/requirements.txt, private dependencies, incompatible runtime version, or the Cloud Build/Artifact Registry API/permissions missing for 2nd gen functions.

Common causes

  • Dependency install failing (version, private repo)
  • Missing main file or wrong runtime
  • Cloud Build API disabled or SA lacks permissions
  • Source directory wrong
  • Artifact Registry permission missing

⚡ Quick fix

  1. Read the Cloud Build log for the failing step
  2. Enable cloudbuild.googleapis.com and artifactregistry.googleapis.com
  3. Pin supported runtime (--runtime nodejs20)

Detailed fix by platform

gcloud

  1. gcloud builds list --limit 3 then gcloud builds log BUILD_ID

How to diagnose

  1. Step — Which build step failed?
  2. APIs — Enabled?
  3. Runtime — Supported?

🔧 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):

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 Build: step exited with non-zero status — Cloud Build: ERROR: build step 2 "gcr.io/cloud-builders/npm" failed: step exited with non-zero status: 1 (Google Cloud / Firebase)Cloud Build: step exi…Cloud Functions: Function execution took 60000 ms, finished with status: timeout — Cloud Functions: Function execution took 60002 ms, finished with status: 'timeout' (Google Cloud / Firebase)Cloud Functions: Func…Cloud Functions: Function failed on loading user code — Cloud Functions: Provided module can't be loaded / Function failed on loading user code. This is likely due to a bug in the user code (Google Cloud / Firebase)Cloud Functions: Func…COPY failed — COPY failed: file not found in build context / "/app/x": not found (Docker)COPY faileddid not complete successfully — failed to solve: process "/bin/sh -c ..." did not complete successfully: exit code: 1 (Docker)did not complete succ…Cloud Fun…

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.