问题
I upgraded my Firebase CLI to version 6.8.0. Now, when I deploy my functions, I get a warning message that looks like this:
⚠ functions: WARNING! NO ENGINES FIELD FOUND IN PACKAGE.JSON. DEFAULTING TO NODE 6 RUNTIME. Starting June 1, 2019 deployments will be blocked if no engines field is specified in package.json. To fix this, add the following lines to your package.json:
"engines": {
"node": "6"
}
What should I do to avoid this error message?
回答1:
The nodejs 6 runtime on Cloud Functions is now deprecated and is being removed, as nodejs 6 has expired Long Term Support (LTS). You can see the LTS schedule for various versions of node here.
The message is displayed now because the Firebased CLI previously took node 6 as a default, but it doesn’t want to break your deployment. You will have to be explicit about which version of node you would like to target for deployment. You can take the advice of the warning message and specify node 6, but since node 6 is EOL, you should target at least node 8 instead, which is now out of beta.
To indicate which version of the node runtime you want, edit your package.json and include a new top-level child to it that looks like this, with a child called “engines”:
{
// other configurations here…
"dependencies": {
},
// Add an “engines” child to choose a node version, here it’s node 8.
"engines": {
"node": "8"
}
}
This requirement is also reflected in the documentation and the default project template created by the Firebase CLI.
If you specifically target node 6, you will see this warning message instead:
⚠ functions: Deploying functions to Node 6 runtime, which is deprecated. Node 8 is available and is the recommended runtime.
来源:https://stackoverflow.com/questions/55960718/firebase-cli-functions-warning-no-engines-field-found-in-package-json-defau