问题
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