Updating cloud function to suitable Node js version

核能气质少年 提交于 2020-06-23 04:11:18

问题


The cloud function for the firebase FCM notification which was working fine with the earlier version of Node.js 8 but now as the node 8 is deprecated and needs to be updated, what changes should I make to the cloud function code, I have already installed Nodejs 14* on my machine


回答1:


The only change you're absolutely required to make is not in your code at all. Minimally, you should edit your package.json and make sure that the target node version is 10:

  "engines": {
    "node": "10"
  },

Simply redeploy the function to use the node 10 runtime.

Read more about migrating your functions to node 10.




回答2:


I'd be careful with that, changing your Node version might break some of your functions. Most of the environment variables are not being set automatically with Node 10 anymore. Some useful links:

https://cloud.google.com/functions/docs/migrating/nodejs-runtimes

https://cloud.google.com/functions/docs/env-var#environment_variables_set_automatically



来源:https://stackoverflow.com/questions/62439837/updating-cloud-function-to-suitable-node-js-version

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