Firebase CLI: “functions: WARNING! NO ENGINES FIELD FOUND IN PACKAGE.JSON. DEFAULTING TO NODE 6 RUNTIME.”

一曲冷凌霜 提交于 2019-12-05 18:35:50

问题


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

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