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.
Error: functions predeploy error: Command terminated with non-zero exit code 1Common 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
- Read the predeploy hooks in
firebase.json. - Run the failing command (lint or build) directly in the functions folder.
- Fix the reported violations, then deploy.
npm --prefix functions run lint
npm --prefix functions run buildKeep predeploy hooks reproducible
Ensure the predeploy hooks install dependencies first so lint and build have what they need in CI.
{
"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.