firebase deploy stops because the predeploy lint step failed
npm --prefix $RESOURCE_DIR run lintShort answer
The predeploy hook in firebase.json runs npm run lint before every deploy, and a failing hook cancels the deploy. ESLint exits with 1 when it finds lint errors or too many warnings, and with 2 when its configuration is broken. Run the lint script yourself, read the exit code, then fix the code or the config.
Fix it fast
1Find out which cause you have
Run the same command the hook runs, from the project root, and print its exit code. The code tells you which cause applies.
npm --prefix functions run lint echo "exit code: $?"2Match what you see, then jump to its fix
What does the error look like?
npm --prefix $RESOURCE_DIR run lintError: There was an error deploying functions
Cause 1 of 3
ESLint found errors in your code (exit code 1)
1Check
Exit code 1 means linting ran and found at least one error.
npm --prefix functions run lint2Fix
Let ESLint repair what it can, then fix the remaining lines by hand.
npm --prefix functions run lint -- --fix3Verify
The lint script ends with exit code 0, then deploy.
npm --prefix functions run lint && echo OK
firebase deploy --only functionsConfirmed by eslint.org
Cause 2 of 3
Warnings exceed the --max-warnings limit (exit code 1)
1Check
If the lint script passes --max-warnings, ESLint exits with 1 once the warning count is above that number, even with zero errors.
grep '"lint"' functions/package.json2Fix
Fix the warnings, or raise the number in the lint script on purpose.
"scripts": { "lint": "eslint . --max-warnings 10" }3Verify
Run the lint script and check the exit code.
npm --prefix functions run lint
echo "exit code: $?"Confirmed by eslint.org
Cause 3 of 3
ESLint failed on its own configuration (exit code 2)
1Check
Exit code 2 means ESLint could not run: a config problem or an internal error. The message above the code names the config file or plugin.
npm --prefix functions run lint2Fix
Fix the config file the message names, or pass the one you mean with -c. If you do not want linting at deploy time, remove the lint entry from the predeploy list.
// firebase.json
"predeploy": []3Verify
A deploy now runs without the lint step; hooks that are listed still run first.
firebase deploy --only functionsConfirmed by eslint.org
How do I stop it coming back?
- Run npm run lint in your editor or a Git hook, so the predeploy hook is never the first place errors show up.
- Lint with the same ESLint version locally and in CI.
- Keep predeploy short: lint and build only.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- WorkforceA field app, an admin console and a self-hosted Node.js server for push and reconciliation.
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- SessionBirdAn omnichannel engagement suite in Flutter: campaigns, chatbot, tickets, analytics and live calling.
Related fixes
Back end
firebase deploy cannot load your functions: user code failed to load
Functions codebase could not be analyzed successfully. It may have a syntax or runtime error
The Firebase CLI loads your functions code on your machine before it deploys, to learn which functions exist.
4 causes, each with a fixBack end
Application Load Balancer returns 502 for a Node.js target
HTTPCode_ELB_502_Count
An ALB returns 502 when the target gives it something it cannot use: a refused or reset connection, a connection closed mid-request, a bad response, or a header over 32 K.
4 causes, each with a fixBack end
corepack enable fails: permission denied while creating the pnpm link
Internal Error: EACCES: permission denied, symlink '../lib/node_modules/corepack/dist/pnpm.js' -> '/usr/local/bin/pnpm'
corepack enable writes small link files for yarn and pnpm next to your node binary.
2 causes, each with a fixBack end
Create React App says Node is too old, and npm will not run on the new one
npm does not support Node.js v10.19.0
The shell is running an old Node.js that is below the version Create React App needs.
3 causes, each with a fixBack end
Firebase Cloud Functions respond slowly, especially on the first call
Every function in the project is slow after deploy, even tiny ones
Most slow first calls are cold starts: the runtime starts from scratch, loads your code and runs global-scope work before it can answer.
3 causes, each with a fixBack end
firebase-admin warns that FIREBASE_CONFIG is missing
Warning, FIREBASE_CONFIG environment variable is missing. Initializing firebase-admin will fail
Cloud Functions for Firebase sets FIREBASE_CONFIG for you; a script run with plain node does not have it.
3 causes, each with a fix