Node.js version and Google Cloud functions

浪尽此生 提交于 2019-12-10 12:32:30

问题


I get this message when I start a local Firebase server with firebase serve:

Warning: You're using Node.js v8.9.4 but Google Cloud Functions only supports v6.11.5.

But there is no info about what to do. What do I need to do to downgrade Node.js to v6.11.5? Should I use that version just for Firebase projects and the latest released version of Node.js for other projects? In that case how to I do that?


EDIT: The warning now looks like this and I am unable to run a new nearly empty project:

Warning: You're using Node.js v8.9.4 but Google Cloud Functions only supports v6.11.5.
!  functions: Failed to load functions source code. Ensure that you have the latest SDK by running npm i --save firebase-functions inside the functions directory.
!  functions: Error from emulator. mod.hasOwnProperty is not a function

So I really think I have to downgrande Node.js. But I do not know how to safely do that. Hm, looking at http://nodejs.org/ I can't even find version v6.11.5?


EDIT 2: Just checked in the new project if npm update --dev fixed the problem. It did not. (Actually no packages where updated.)


回答1:


That's just a warning. You can ignore it if you know what you're doing. It's telling you that your local emulation of a function (running on node 8.9.4) may not perfectly match what the function will do when it's deployed to Cloud Functions (running 6.11.5). But as long as you're not using any features of node that are not available on node 6.11.5, you won't have a problem. I use newer versions of node to test locally all the time without problems.




回答2:


You can uninstall and reinstall Cloud Functions emulator and Firebase Tools using the commands provided in the GitHub Troubleshooting guide. Since you are using Firebase, follow the instruction for the ‘Firebase Tools’.




回答3:


Node v8 is now available for cloud functions: https://firebase.googleblog.com/2018/08/cloud-functions-for-firebase-config-node-8-timeout-memory-region.html

So I believe this warning can truly be ignored...




回答4:


There are several tools listed in the answers to this question

For Windows I just used nvmw successfully to accomplish this same task.




回答5:


You will get the nvm here

After installation of nvm. just use this command "nvm install 8.9.1 64bit" you can use any version here or 64bit 32bit according to your system config after that installation use "nvm use 8.9.1"



来源:https://stackoverflow.com/questions/50001512/node-js-version-and-google-cloud-functions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!