Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Node.js, PHP and APIs

firebase deploy stops because the predeploy lint step failed

Errornpm --prefix $RESOURCE_DIR run lint

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

  • Applies to firebase-tools 14, Node.js 22, ESLint 9, Ubuntu 24.04
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 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: $?"
  2. 2Match what you see, then jump to its fix

    1. 1exit code: 1 and a list of file:line problemsESLint found errors in your code (exit code 1)Fix
    2. 2exit code: 1 with only warnings listedWarnings exceed the --max-warnings limit (exit code 1)Fix
    3. 3exit code: 2ESLint failed on its own configuration (exit code 2)Fix

What does the error look like?

  • npm --prefix $RESOURCE_DIR run lint
  • Error: 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 lint

2Fix

Let ESLint repair what it can, then fix the remaining lines by hand.

npm --prefix functions run lint -- --fix

3Verify

The lint script ends with exit code 0, then deploy.

npm --prefix functions run lint && echo OK
firebase deploy --only functions

Confirmed by eslint.org

Did this fix it?

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

2Fix

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

Did this fix it?

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 lint

2Fix

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 functions

Confirmed by eslint.org

Did this fix it?

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:

Related fixes

Back 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

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.