Skip to content
Latchkey

Firebase "functions predeploy error: Command terminated with non-zero exit code" in CI

The functions.predeploy hooks in firebase.json (typically lint and build) run before deploy. One of them exited non-zero, so the CLI stops. The failing command output is printed just above this line.

What this error means

A functions deploy stops with "Error: functions predeploy error: Command terminated with non-zero exit code 1" after a lint or build hook.

firebase
Error: functions predeploy error: Command terminated with non-zero exit code 1

Common causes

A lint error in the predeploy hook

The npm run lint predeploy command found violations and exited 1, blocking the deploy.

A build failure in the predeploy hook

A TypeScript compile error in the npm run build predeploy hook exits non-zero.

How to fix it

Run the predeploy command directly to see the error

  1. Read the predeploy hooks in firebase.json.
  2. Run the failing command (lint or build) directly in the functions folder.
  3. Fix the reported violations, then deploy.
Terminal
npm --prefix functions run lint
npm --prefix functions run build

Keep predeploy hooks reproducible

Ensure the predeploy hooks install dependencies first so lint and build have what they need in CI.

firebase.json
{
  "functions": {
    "predeploy": ["npm --prefix functions ci", "npm --prefix functions run lint", "npm --prefix functions run build"]
  }
}

How to prevent it

  • Run lint and build in CI before the deploy step, matching the predeploy hooks.
  • Install functions dependencies in the predeploy hook.
  • Fix lint and type errors before merging.

Frequently asked questions

What causes ""predeploy error: non-zero exit code""?
The npm run lint predeploy command found violations and exited 1, blocking the deploy.
How do I fix "predeploy error: non-zero exit code"?
Run the predeploy command directly to see the error

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card