Firebase部署问题-nodeJS版本

时间:2018-08-01 23:52:47

标签: node.js firebase npm firebase-cli

当我想使用Firebase部署项目时,遇到了nodeJS版本问题,这困扰了我很多天。 当我应用命令“ firebase deploy --only functions”时,它使我想起:

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

我的节点版本是v8.11.3 我的npm版本是6.2.0

有人知道如何解决吗?非常感谢!!!

1 个答案:

答案 0 :(得分:0)

遇到了同样的问题。将Node JS版本更新为v8.16.0,然后在我的Functions / package.json中添加了nodeJS引擎版本:

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

我现在能够部署我的功能。

在这里找到答案:https://howtofirebase.com/cloud-functions-migrating-to-node-8-9640731a8acc