Open ziziele opened 1 year ago
Hi ziziele, does a regular npm install
add the modules when run from the functions directory? I only see an npm i stripe
in the bug report which may not install all required modules.
Hi Chris,
I initially used npm i stripe
only once before deploying my code. However, when I deployed it, I encountered an error, which prompted me to delete the node_modules
folder and package_lock.json
file. Afterward, I ran npm install
, all inside the functions
directory.
Despite repeating these steps several times, the error persisted. To troubleshoot the error, I manually installed the request packages indicated in the error message using npm install
. However, as I installed more packages, it required more whenever I ran firebase deploy --only functions
. My package-lock.json
file now contains hundreds of packages.
Is this a problem with Firebase or is the project corrupted? Is it possible to reproduce the error in a fresh project?
Hi Chris, I've just tested with a fresh project and it has the same error.
These were the steps I took:
npm install firebase-functions@latest firebase-admin@latest --save
npm install -g firebase-tools
firebase login
firebase init functions
JavaScript
npm install
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!"); });
8. ` 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](https://github.com/firebase/firebase-tools/files/11206075/error.zip)
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
, or11.22.0
. Mostly they prefer to downgrade it to11.17.0
.
npm i -g firebase-tools@11.17.0
Or at least it works for me.
Following the steps above but I'm not able to repro
Node: v18.13.0 firebase-tools version: 11.25.3 OS: Ubuntu variant
Based on the S.O. Answer it's a problem finding functions.yaml - I'll continue investigating
Question: Do you have anything non-default in npmrc?
npm config list
Also @ziziele - do you mind sharing the version of node you are using locally and the version you are specifying when deploying to GCF?
e.g.
node -v
Hi @taeold. I face the same issue with Firebase 11.27.0. I've recently upgraded my version of node from 16.16 to 18.16. The problem occurs in both cases.
Possibly related S.O. question https://stackoverflow.com/questions/76121723/what-is-functions-yaml
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.
Hey @ziziele. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 3 days I will close it automatically.
If you have more information that will help us get to the bottom of this, just add a comment!
Same issue and this resolves it:
Update: Removing the package-lock.json file before deploying seems to fix it everytime.
Node.js v18.16.0. Firebase 12.1.0 npm 9.6.7 Windows 11
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 runningnpm install
. The error reappears soon as I change the engine back to 18, remove the node_modules and runnpm 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.
You should not remove the package-lock before deployment. That is a security and potential breaking change nightmare waiting to happen.
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.
This issue is not solved. While deploying the latest functions build success. But in logs the same error.
{ "protoPayload": { "@type": "type.googleapis.com/google.cloud.audit.AuditLog", "status": { "code": 3, "message": "Build failed: ...: lines-and-columns@1.2.4 from lock file\nnpm ERR! Missing: is-arrayish@0.2.1 from lock file\nnpm ERR! Missing: ansi-styles@5.2.0 from lock file\nnpm ERR! Missing: react-is@18.2.0 from lock file\nnpm ERR! Missing: kleur@3.0.3 from lock file\nnpm ERR! Missing: sisteransi@1.0.5 from lock file\nnpm ERR! Missing: is-core-module@2.12.1 from lock file\nnpm ERR! Missing: path-parse@1.0.7 from lock file\nnpm ERR! Missing: supports-preserve-symlinks-flag@1.0.0 from lock file\nnpm ERR! Missing: shebang-regex@3.0.0 from lock file\nnpm ERR! Missing: buffer-from@1.1.2 from lock file\nnpm ERR! Missing: char-regex@1.0.2 from lock file\nnpm ERR! Missing: glob@7.2.3 from lock file\nnpm ERR! Missing: minimatch@3.1.2 from lock file\nnpm ERR! Missing: is-number@7.0.0 from lock file\nnpm ERR! Missing: picocolors@1.0.0 from lock file\nnpm ERR! Missing: convert-source-map@1.9.0 from lock file\nnpm ERR! Missing: makeerror@1.0.12 from lock file\nnpm ERR! Missing: tmpl@1.0.5 from lock file\nnpm ERR! Missing: isexe@2.0.0 from lock file\nnpm ERR! Missing: imurmurhash@0.1.4 from lock file\nnpm ERR! Missing: ms@2.1.2 from lock file\nnpm ERR! Missing: yallist@3.1.1 from lock file\nnpm ERR! Missing: ansi-styles@3.2.1 from lock file\nnpm ERR! Missing: escape-string-regexp@1.0.5 from lock file\nnpm ERR! Missing: supports-color@5.5.0 from lock file\nnpm ERR! Missing: color-convert@1.9.3 from lock file\nnpm ERR! Missing: color-name@1.1.3 from lock file\nnpm ERR! Missing: has-flag@3.0.0 from lock file\nnpm ERR! Missing: ms@2.1.2 from lock file\nnpm ERR! Missing: minimatch@3.1.2 from lock file\nnpm ERR! Missing: brace-expansion@1.1.11 from lock file\nnpm ERR! Missing: ms@2.1.2 from lock file\nnpm ERR! Missing: minimatch@3.1.2 from lock file\nnpm ERR! Missing: brace-expansion@1.1.11 from lock file\nnpm ERR! Missing: minimatch@3.1.2 from lock file\nnpm ERR! Missing: brace-expansion@1.1.11 from lock file\nnpm ERR! Missing: sprintf-js@1.0.3 from lock file\nnpm ERR! Missing: p-try@2.2.0 from lock file\nnpm ERR! Missing: brace-expansion@1.1.11 from lock file\nnpm ERR! \nnpm ERR! Clean install a project\nnpm ERR! \nnpm ERR! Usage:\nnpm ERR! npm ci\nnpm ERR! \nnpm ERR! Options:\nnpm ERR! [-S|--save|--no-save|--save-prod|--save-dev|--save-optional|--save-peer|--save-bundle]\nnpm ERR! [-E|--save-exact] [-g|--global]\nnpm ERR! [--install-strategy <hoisted|nested|shallow|linked>] [--legacy-bundling]\nnpm ERR! [--global-style] [--omit <dev|optional|peer> [--omit <dev|optional|peer> ...]]\nnpm ERR! [--strict-peer-deps] [--no-package-lock] [--foreground-scripts]\nnpm ERR! [--ignore-scripts] [--no-audit] [--no-bin-links] [--no-fund] [--dry-run]\nnpm ERR! [-w|--workspace <workspace-name> [-w|--workspace <workspace-name> ...]]\nnpm ERR! [-ws|--workspaces] [--include-workspace-root] [--install-links]\nnpm ERR! \nnpm ERR! aliases: clean-install, ic, install-clean, isntall-clean\nnpm ERR! \nnpm ERR! Run \"npm help ci\" for more info\n\nnpm ERR! A complete log of this run can be found in:\nnpm ERR! /www-data-home/.npm/_logs/2023-06-21T06_17_19_692Z-debug-0.log; Error ID: beaf8772" }, "authenticationInfo": {}, "serviceName": "cloudfunctions.googleapis.com", "methodName": "google.cloud.functions.v1.CloudFunctionsService.CreateFunction", "resourceName": "projects/content-magic-tool/locations/us-central1/functions/authOnCreate" }, "insertId": "-oekmvud1nti", "resource": { "type": "cloud_function", "labels": { "region": "us-central1", "project_id": "content-magic-tool", "function_name": "authOnCreate" } }, "timestamp": "2023-06-21T06:17:31.521862Z", "severity": "ERROR", "logName": "projects/content-magic-tool/logs/cloudaudit.googleapis.com%2Factivity", "operation": { "id": "operations/Y29udGVudC1tYWdpYy10b29sL3VzLWNlbnRyYWwxL2F1dGhPbkNyZWF0ZS9XSjhET183UDZkSQ", "producer": "cloudfunctions.googleapis.com", "last": true }, "receiveTimestamp": "2023-06-21T06:17:32.401975695Z" }
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'm encountering the exact same issue. Builds fine, but when trying to deploy, getting multiple errors all looking the same :
Build failed: ...path-exists@3.0.0 from lock file
npm ERR! Missing: p-limit@2.3.0 from lock file
npm ERR! Missing: p-try@2.2.0 from lock file
npm ERR! Missing: ms@2.1.2 from lock file
npm ERR! Missing: cliui@8.0.1 from lock file
I recently upgraded to node 18.
All the versions would be :
I removed node_modules and package-lock.json before doing a clean npm install with the same errors at the end.
I investigated a few of the packages :
`-- firebase-admin@11.10.1
`-- @google-cloud/storage@6.12.0
`-- p-limit@3.1.0
+-- firebase-admin@11.10.1
| `-- @google-cloud/firestore@6.7.0
| `-- google-gax@3.6.1
| `-- @grpc/proto-loader@0.7.8
| `-- yargs@17.7.2
| `-- cliui@8.0.1
`-- firebase@10.1.0
`-- @firebase/firestore@4.1.0
+-- @grpc/grpc-js@1.8.21
| `-- @grpc/proto-loader@0.7.8
| `-- yargs@17.7.2
| `-- cliui@8.0.1
`-- @grpc/proto-loader@0.6.13
`-- yargs@16.2.0
`-- cliui@7.0.4
npm list p-try
returns nothing, so... Not sure if that means anything as I never had to bother checking for that kind of stuff before, so I lack comparisons on that, but maybe that will give an idea to someone more knowledgeable than me on that topic.
Also FWIW, I'm trying to deploy functions v1 and v2.
By removing the package-lock.json, all the v1 functions managed to deploy, and the v2 failed, but that was my mistake as I had calls to functions.config(). I'll have to look into that, but that's unrelated.
As my project is 2 years old, I wondered if I'm not missing anything that was added afterwards. So I created a new project and its functions folder, uncommented the helloWorld function and tried to deploy it, with the same error (as @ziziele) did.
This issue started appearing while deploying my cloud functions a week ago. I could not find a solution and was getting mad. I read and tried every information on the internet to resolve the error, but no success.
Finally, I decided to reset my machine, and then tried to redeploy the cloud function with the exact same configuration and versions and this time it worked!
Also, thoroughly comparing I found that when we install NodeJS on our machine , with all the required packages python311 also gets installed which helps in downloading of the missing dependencies mentioned in the error and i had deleted python311 folder from C drive thinking it as junk which might is causing all the trouble.
I hope my comment helps in resolving the issue!🫡
This is still not solved. I encounter exactly the same problem.
The only thing that works for me is deleting package-lock.json
before deployment. However, as @michaelangeloio has already pointed out, this is not a good idea.
Edit: I also tried npm config set legacy-peer-deps false
and npm ci
as suggested here, but it did not work. Contrary to @sebastien-f, I am experiencing the issue on a Mac.
Removing package-lock seems fine to me.
Removing package-lock seems fine to me.
https://stackoverflow.com/a/54127283/111625. Short version :
Conclusion: don't ever delete package-lock.json.
That being said, in many scenarios that won't be an issue, but why makes the symptom disappear instead of curing the illness ?
This is still not solved. I encounter exactly the same problem.
The only thing that works for me is deleting
package-lock.json
before deployment. However, as @michaelangeloio has already pointed out, this is not a good idea.Edit: I also tried
npm config set legacy-peer-deps false
andnpm ci
as suggested here, but it did not work. Contrary to @sebastien-f, I am experiencing the issue on a Mac.
After running the config set command from npm, try running npm config list
to make sure that it was taken into account. You should see a line with : legacy-peer-deps = false
, not starting with a ;
.
If that's not it, if you can share somewhere the full error log from google cloud console regarding the deployment, I can offer to have a look at it, to see if something strikes me. If I remember correctly, firebase should provide a link to it when it fails.
When running npm config list
I indeed get legacy-peer-deps = false
.
I exported the error log from Google Cloud Console (see below). However, as it is very long and repetitive in the middle, I replaced one part with ...
.
Thank you very much in advance!
It's a bit different from what I had (not by a large account, but still). If you did not tried it yet, what you could also do would be moving your node_modules and package-lock.json outside of your project directory (you could delete them also, but you never know) and then run npm install
again, then try to deploy it, just to make sure that it's really up to date with your project.
Also, not sure if you can, but I'd try copying the project to another computer (even a virtual machine), then npm install
and then trying to deploy it from that other machine, just to see if that's not something specific on your mac.
Thank you! I already tried to delete node_modules
and package-lock.json
and run npm install
again. Unfortunately, that did not work.
I will try to run it on a Windows machine (or virtual machine) later.
I am also experiencing this. It is very strange, but once the functions emulator fails to start up, the next time it succeeds in starting up the emulator.
# fail!!
$ cd functions && rm -rf build && npm ci && firebase emulators:start --only functions
# success!!
$ cd functions && rm -rf build && npm ci && firebase emulators:exec --only functions "echo hello" && firebase emulators:start --only functions
I am still experiencing this issue.
npm ERR!
npm ERR! npm ci
can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync. Please update your lock file with npm install
before continuing.
npm ERR!
npm ERR! Missing: ms@2.0.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! [--install-strategy <hoisted|nested|shallow|linked>] [--legacy-bundling]
npm ERR! [--global-style] [--omit <dev|optional|peer> [--omit <dev|optional|peer> ...]]
npm ERR! [--include <prod|dev|optional|peer> [--include <prod|dev|optional|peer> ...]]
npm ERR! [--strict-peer-deps] [--foreground-scripts] [--ignore-scripts] [--no-audit]
npm ERR! [--no-bin-links] [--no-fund] [--dry-run]
npm ERR! [-w|--workspace
remove package-lock.json. thats what ive been doing and its worked for months ever since
@ekaram it may not be best idea or even good practice, but at the end of the day that's all that works and has ever. no other solutions above do sh*t
I am getting this error when i am trying to tsc --watch
. If a code throws an exception inside a function i try to change the code and build the project the code is built but i get this error
Add this line into terminal V Code
sudo npm install -g firebase-tools
I'm having the same problem:
Build failed with status: FAILURE and message: npm ERR! code EUSAGE
npm ERR!
npm ERR! npm ci
can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync. Please update your lock file with npm install
before continuing.
npm ERR!
npm ERR! Missing: string-width-cjs@4.2.3 from lock file
npm ERR! Missing: strip-ansi-cjs@6.0.1 from lock file
npm ERR! Missing: wrap-ansi-cjs@7.0.0 from lock file
npm ERR! Missing: safe-buffer@5.1.2 from lock file
npm ERR! Missing: safe-buffer@5.1.2 from lock file
npm ERR! Missing: safe-buffer@5.1.2 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! [--install-strategy <hoisted|nested|shallow|linked>] [--legacy-bundling]
npm ERR! [--global-style] [--omit <dev|optional|peer> [--omit <dev|optional|peer> ...]]
npm ERR! [--include <prod|dev|optional|peer> [--include <prod|dev|optional|peer> ...]]
npm ERR! [--strict-peer-deps] [--foreground-scripts] [--ignore-scripts] [--no-audit]
npm ERR! [--no-bin-links] [--no-fund] [--dry-run]
npm ERR! [-w|--workspace
@ytetsuro I have the exact same problem. Running it twice consistently works.
I like your solution. It seems like you've also spent a lot of time to fix this. You definitely read the docs.
I'd like to know if there is a more elegant fix in the future.
Facing similar issue while deploying cloud function
removing package-lock.json
before deploying fixed this issue for me. But this is not a proper solution.
(Some more details that might help others coming from Google search find this.)
When I deploy the functions with package-lock.json
existing, I get the error:
=== Node.js - Npm (google.nodejs.npm@1.1.0) ===
***** CACHE MISS: "npm_modules"
Installing application dependencies.
--------------------------------------------------------------------------------
Running "npm ci --quiet (NODE_ENV=production)"
npm error Exit handler never called!
npm error This is an error with npm itself. Please report this error at:
npm error <https://github.com/npm/cli/issues>
npm error A complete log of this run can be found in: /www-data-home/.npm/_logs/2024-07-15T19_50_02_938Z-debug-0.log
Done "npm ci --quiet (NODE_ENV=production)" (7m41.268669372s)
--------------------------------------------------------------------------------
failed to build: (error ID: beaf8772):
Timer: Builder ran for 7m44.29164638s and ended at 2024-07-15T19:57:44Z
ERROR: failed to build: exit status 1
@christhompsongoogle does this look like another symptom of the same issue? Now npm ci
is hitting some internal crash. I don't know how I can get access to /www-data-home/.npm/_logs
of my firebase function Cloud Build but that might have some more enlightening facts. If this is a new problem I can instead make a new github issue?
When I delete the lock file or add "package-lock.json"
to firebase.json's functions.ignore[]
then I get a successful build, although it adds some extra build time to recreate the lock file...
=== Node.js - Npm (google.nodejs.npm@1.1.0) ===
Generating package-lock.json.
WARNING: *** Improve build performance by generating and committing package-lock.json.
--------------------------------------------------------------------------------
Running "npm install --package-lock-only --quiet"
up to date, audited 868 packages in 15s
Done "npm install --package-lock-only --quiet" (15.222930181s)
***** CACHE MISS: "npm_modules"
Installing application dependencies.
--------------------------------------------------------------------------------
Running "npm ci --quiet (NODE_ENV=production)"
added 275 packages, and audited 276 packages in 8s
Done "npm ci --quiet (NODE_ENV=production)" (8.33702695s)
=== Node.js - Functions Framework (google.nodejs.functions-framework@0.9.4) ===
--------------------------------------------------------------------------------
Running "node --check index.js"
....
I updated multiple things before I could successfully deploy firebase functions. It took some while, but I did solve it:
In the end it all worked out.
I'm experiencing this same issue. Frustrating that so many people are reporting it, yet this is closed with no solution. :(
@saldous did you try deleting package-lock.json?
@saldous did you try deleting package-lock.json?
yes, while that works I'm sure that's not the official solution/fix? It's a temporary workaround.
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:
package.json
firebase.json
.gitignore
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:
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.