0

when I want to deploy my project with firebase, I encountered the nodeJS version problem and it troubled me for many days. when I apply the command "firebase deploy --only functions", then it reminds me that:

i  deploying functions
Running command: npm --prefix functions install
audited 5522 packages in 8.196s
found 11 vulnerabilities (2 low, 5 moderate, 4 high)
run `npm audit fix` to fix them, or `npm audit` for details
✔  functions: Finished running predeploy script.
i  functions: ensuring necessary APIs are enabled...
✔  functions: all necessary APIs are enabled
i  functions: preparing functions directory for uploading...

Error: Error occurred while parsing your function triggers.

Error: The module 
was compiled against a different Node.js version using
NODE_MODULE_VERSION 48. This version of Node.js requires
NODE_MODULE_VERSION 57. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
at Object.Module._extensions..node (module.js:681:18)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> 
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)

Having trouble? Try firebase deploy --help

my node version is v8.11.3 my npm version is 6.2.0

Anyone knows how to solve it?? Thank you very much!!!

Lei Zhao
  • 1
  • 1
  • I tried all the solution I can find like "npm update" "npm install", but they all don't work. Also, I tried many other versions of nodejs but no one can solve this problem. – Lei Zhao Aug 02 '18 at 00:02
  • Try `npm rebuild`, or barring that, `rm -rf node_modules` in your functions directory and run `npm install` again. – Michael Bleigh Aug 02 '18 at 00:37
  • Don't show images of errors and code. Copy the text into a the question itself so it's easy to read and search. – Doug Stevenson Aug 02 '18 at 01:07
  • I tried "npm rebuild" and "rm -rf node_modules", also "npm install". They all don't work. Is there other reason which can cause this problem?? – Lei Zhao Aug 02 '18 at 07:22

1 Answers1

0

Was running into the same issues. Updated my Node JS version to v8.16.0, then within my Functions / package.json I added the nodeJS engine version:

 "engines": { "node": "8" },

I am now able to deploy my functions.

Found the answer here: https://howtofirebase.com/cloud-functions-migrating-to-node-8-9640731a8acc

B. Davis
  • 71
  • 1
  • 3