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: [email protected] from lock file
npm ERR! Missing: [email protected] from lock file
npm ERR! Missing: [email protected] from lock file
npm ERR! Missing: [email protected] from lock file
npm ERR! Missing: [email protected] from lock file
npm ERR! Missing: [email protected] from lock file
npm ERR! Missing: [email protected] from lock file
npm ERR! Missing: [email protected] from lock file
npm ERR! Missing: [email protected] from lock file
npm ERR! Missing: [email protected] from lock file
npm ERR! Missing: [email protected] from lock file
npm ERR! Missing: [email protected] from lock file
npm ERR! Missing: [email protected] from lock file
npm ERR! Missing: [email protected] from lock file
npm ERR! Missing: [email protected] from lock file
npm ERR! Missing: [email protected] from lock file
npm ERR! Missing: [email protected] from lock file
npm ERR! Missing: [email protected] from lock file
npm ERR! Missing: [email protected] from lock file
npm ERR! Missing: [email protected] from lock file
npm ERR! Missing: [email protected] from lock file
npm ERR! Missing: [email protected] from lock file
npm ERR! Missing: [email protected] from lock file
npm ERR! Missing: [email protected] from lock file
npm ERR! Missing: [email protected] from lock file
npm ERR! Missing: [email protected] from lock file
npm ERR! Missing: [email protected] from lock file
npm ERR! Missing: [email protected] from lock file
npm ERR! Missing: [email protected] from lock file
npm ERR! Missing: [email protected] from lock file
npm ERR! Missing: [email protected] from lock file
npm ERR! Missing: [email protected] from lock file
npm ERR! Missing: [email protected] from lock file
npm ERR! Missing: [email protected] from lock file
npm ERR! Missing: [email protected] from lock file
npm ERR! Missing: [email protected] from lock file
npm ERR! Missing: [email protected] from lock file
npm ERR! Missing: [email protected] from lock file
npm ERR! Missing: [email protected] from lock file
npm ERR! Missing: [email protected] from lock file
npm ERR! Missing: [email protected] 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": "^10.0.0",
"firebase-functions": "^4.0.0",
"stripe": "^8.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"
]
}
]
}
I don’t have .gcloudignore
but .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, and I would greatly appreciate any guidance or suggestions on how to fix it. Thank you for your help.
2
Answers
After reproducing your issue, I took the following steps to debug it.
There are a few things that you should check before starting the debugging process:
I have checked
firebase-debug.log
in this issue and it containsCould not find functions.yaml. Must use http discovery
:After reading a similar issue, I see that they recommend downgrading
firebase-tools
to10.0.0
,10.8.0
,11.17.0
,11.18.0
,11.20.0
, or11.22.0
. Mostly they prefer to downgrade it to11.17.0
.