firebase-tools: Firebase function deployment fails with 'missing' dependencies error

I am encountering an error when attempting to deploy a Firebase function. Despite deleting node_modules and package-lock.json, running npm install, and executing firebase deploy --only functions many times, the build process still fails with the following error:

Build failed: ...regex-range@5.0.1 from lock file
npm ERR! Missing: brace-expansion@1.1.11 from lock file
npm ERR! Missing: balanced-match@1.0.2 from lock file
npm ERR! Missing: concat-map@0.0.1 from lock file
npm ERR! Missing: mimic-fn@2.1.0 from lock file
npm ERR! Missing: p-limit@2.3.0 from lock file
npm ERR! Missing: error-ex@1.3.2 from lock file
npm ERR! Missing: json-parse-even-better-errors@2.3.1 from lock file
npm ERR! Missing: lines-and-columns@1.2.4 from lock file
npm ERR! Missing: is-arrayish@0.2.1 from lock file
npm ERR! Missing: ansi-styles@5.2.0 from lock file
npm ERR! Missing: react-is@18.2.0 from lock file
npm ERR! Missing: kleur@3.0.3 from lock file
npm ERR! Missing: sisteransi@1.0.5 from lock file
npm ERR! Missing: is-core-module@2.11.0 from lock file
npm ERR! Missing: path-parse@1.0.7 from lock file
npm ERR! Missing: supports-preserve-symlinks-flag@1.0.0 from lock file
npm ERR! Missing: shebang-regex@3.0.0 from lock file
npm ERR! Missing: buffer-from@1.1.2 from lock file
npm ERR! Missing: escape-string-regexp@2.0.0 from lock file
npm ERR! Missing: char-regex@1.0.2 from lock file
npm ERR! Missing: has-flag@4.0.0 from lock file
npm ERR! Missing: is-number@7.0.0 from lock file
npm ERR! Missing: picocolors@1.0.0 from lock file
npm ERR! Missing: convert-source-map@1.9.0 from lock file
npm ERR! Missing: makeerror@1.0.12 from lock file
npm ERR! Missing: tmpl@1.0.5 from lock file
npm ERR! Missing: isexe@2.0.0 from lock file
npm ERR! Missing: ms@2.1.2 from lock file
npm ERR! Missing: yallist@3.1.1 from lock file
npm ERR! Missing: ansi-styles@3.2.1 from lock file
npm ERR! Missing: escape-string-regexp@1.0.5 from lock file
npm ERR! Missing: supports-color@5.5.0 from lock file
npm ERR! Missing: color-convert@1.9.3 from lock file
npm ERR! Missing: color-name@1.1.3 from lock file
npm ERR! Missing: has-flag@3.0.0 from lock file
npm ERR! Missing: ms@2.1.2 from lock file
npm ERR! Missing: ms@2.1.2 from lock file
npm ERR! Missing: cliui@8.0.1 from lock file
npm ERR! Missing: yargs-parser@21.1.1 from lock file
npm ERR! Missing: p-try@2.2.0 from lock file
npm ERR!
npm ERR! Clean install a project
npm ERR!
npm ERR! Usage:
npm ERR! npm ci
npm ERR!
npm ERR! Options:
npm ERR! [-S|--save|--no-save|--save-prod|--save-dev|--save-optional|--save-peer|--save-bundle]      
npm ERR! [-E|--save-exact] [-g|--global] [--global-style] [--legacy-bundling]
npm ERR! [--omit <dev|optional|peer> [--omit <dev|optional|peer> ...]]
npm ERR! [--strict-peer-deps] [--no-package-lock] [--foreground-scripts]
npm ERR! [--ignore-scripts] [--no-audit] [--no-bin-links] [--no-fund] [--dry-run]
npm ERR! [-w|--workspace <workspace-name> [-w|--workspace <workspace-name> ...]]
npm ERR! [-ws|--workspaces] [--include-workspace-root] [--install-links]
npm ERR!
npm ERR! aliases: clean-install, ic, install-clean, isntall-clean
npm ERR!
npm ERR! Run "npm help ci" for more info

npm ERR! A complete log of this run can be found in:
npm ERR!     /www-data-home/.npm/_logs/2023-04-09T09_55_08_623Z-debug-0.log; Error ID: beaf8772      

Functions deploy had errors with the following functions:
        update(asia-east2)
i  functions: cleaning up build files...

Error: There was an error deploying functions

package.json

{
  "name": "functions",
  "description": "Cloud Functions for Firebase",
  "scripts": {
    "serve": "firebase emulators:start --only functions",
    "shell": "firebase functions:shell",
    "start": "npm run shell",
    "deploy": "firebase deploy --only functions",
    "logs": "firebase functions:log"
  },
  "main": "index.js",
  "dependencies": {
    "firebase-admin": "^11.5.0",
    "firebase-functions": "^4.2.0",
    "stripe": "^12.0.0"
  },
  "devDependencies": {
    "firebase-functions-test": "^3.0.0"
  },
  "private": true,
  "engines": {
    "node": "16"
  }
}

firebase.json

{
  "functions": [
    {
      "source": "functions",
      "codebase": "default",
      "ignore": [
        "node_modules",
        ".git",
        "firebase-debug.log",
        "firebase-debug.*.log"
      ]
    }
  ]
}

.gitignore

node_modules/

I have manually npm installed each of them but anytime I execute firebase deploy --only functions, it keeps asking for more. Now my package-lock.json has hundreds of packages.

The code I’m testing:

exports.helloWorld = functions
  .region("asia-east2")
  .https.onRequest((request, response) => {
    functions.logger.info("Hello logs!", { structuredData: true });
    response.send("Hello from Firebase!");
  });

The steps I took:

npm install -g firebase-tools

firebase login

firebase init functions - Use an existing project …

cd functions

npm i stripe

edit index.js

firebase deploy --only functions

On the Firebase Dashboard, this function is indicated by a red triangle with the message ‘Function deployment failed. Please try again.’

I have also tried updating the affected packages in my package.json file, but the error persists.

I am unsure what could be causing this issue.

About this issue

  • Original URL
  • State: open
  • Created a year ago
  • Comments: 30 (8 by maintainers)

Most upvoted comments

Hi Chris, I’ve just tested with a fresh project and it has the same error.

These were the steps I took:

  1. npm install firebase-functions@latest firebase-admin@latest --save
  2. npm install -g firebase-tools
  3. firebase login
  4. firebase init functions
  5. JavaScript
  6. npm install
  7. cd functions and modified the existing index.js to:
const functions = require("firebase-functions");

// // Create and deploy your first functions
// // https://firebase.google.com/docs/functions/get-started
//
exports.helloWorld = functions.https.onRequest((request, response) => {
  functions.logger.info("Hello logs!", { structuredData: true });
  response.send("Hello from Firebase!");
});
  1. firebase deploy --only functions

I have attached all the necessary files, including the firebase.json and the functions/package.json files, and the output log of the firebase-debug.log after running the deploy command with the debug flag. error.zip

Since there haven’t been any recent updates here, I am going to close this issue.

@ziziele if you’re still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.

I’ve been chasing this problem all evening, I changed the engine field in the package.json file from 18 to 16 and it works after removing the node_module and running npm install. I was able to get the cloud function to also update by changing the engine to 18 BUT not running npm install. The error reappears soon as I change the engine back to 18, remove the node_modules and run npm install again.

I am running the latest firebase-tools, firebase-admin, and firebase-functions.

Update: Removing the package-lock.json file before deploying seems to fix it everytime.

Hi Chris,

I posted it on StackOverFlow and this is the right answer: https://stackoverflow.com/a/76044520/12640100

After reading a similar issue, I see that they recommend downgrading firebase-tools to 10.0.0, 10.8.0, 11.17.0, 11.18.0, 11.20.0, or 11.22.0. Mostly they prefer to downgrade it to 11.17.0.

npm i -g firebase-tools@11.17.0

Or at least it works for me.

remove package-lock.json. thats what ive been doing and its worked for months ever since

Removing package-lock seems fine to me.