简体   繁体   English

Node.js版本和Google Cloud功能

[英]Node.js version and Google Cloud functions

I get this message when I start a local Firebase server with firebase serve : 当我使用firebase serve启动本地Firebase服务器时收到此消息:

Warning: You're using Node.js v8.9.4 but Google Cloud Functions only supports v6.11.5. 警告:您使用的是Node.js v8.9.4,但Google Cloud Functions仅支持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? 将Node.js降级到v6.11.5需要做什么? Should I use that version just for Firebase projects and the latest released version of Node.js for other projects? 我是应该仅为Firebase项目使用该版本,还是为其他项目使用最新发布的Node.js版本? 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. 所以我真的认为我必须降级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? 嗯,看着http://nodejs.org/我甚至找不到版本v6.11.5?


EDIT 2: Just checked in the new project if npm update --dev fixed the problem. 编辑2:刚刚检查了新项目,如果npm update --dev修复了问题。 It did not. 它没。 (Actually no packages where updated.) (实际上没有更新的包。)

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). 它告诉您,函数的本地仿真(在节点8.9.4上运行)可能与函数部署到云函数(运行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. 但只要您没有使用节点6.11.5上没有的任何节点功能,就不会有问题。 I use newer versions of node to test locally all the time without problems. 我使用较新版本的节点一直在本地测试而没有问题。

You can uninstall and reinstall Cloud Functions emulator and Firebase Tools using the commands provided in the GitHub Troubleshooting guide. 您可以使用GitHub 故障排除指南中提供的命令卸载并重新安装Cloud Functions模拟器和Firebase工具。 Since you are using Firebase, follow the instruction for the 'Firebase Tools'. 由于您使用的是Firebase,请按照“Firebase工具”的说明操作。

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 Node v8现在可用于云功能: 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... 所以我相信这个警告真的可以忽略......

There are several tools listed in the answers to this question 问题的答案中列出了几种工具

For Windows I just used nvmw successfully to accomplish this same task. 对于Windows,我刚刚成功使用nvmw来完成同样的任务。

You will get the nvm here 你会在这里获得nvm

After installation of nvm. 安装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" 只需使用此命令“nvm install 8.9.1 64bit”,您可以使用此处的任何版本或64bit 32bit根据您的系统配置安装后使用“nvm use 8.9.1”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM