本文介绍了Firebase CLI:"功能:警告!在PACKAGE.JSON中找不到引擎字段.默认为运行时的NODE6."的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将Firebase CLI升级到了6.8.0版.现在,当我部署功能时,会收到一条警告消息,如下所示:

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:

 "engines": {
   "node": "6"
 }

如何避免出现此错误消息?

What should I do to avoid this error message?

推荐答案

由于Node.js 6的长期支持(LTS)已过期,因此现在不建议使用Cloud Functions上的Node.js 6运行时并将其删除.您可以在此处看到各种版本的节点的LTS时间表.

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.

现在显示该消息是因为Firebased CLI以前将节点6作为默认节点,但它不希望中断您的部署.您必须明确要部署的目标节点版本.您可以听取警告消息的建议并指定节点6,但是由于节点6是EOL,因此您应该至少定位到节点8,而现在它已经超出beta了.

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.

要指示所需的节点运行时版本,请编辑package.json并为其添加一个新的顶级子级,该子级如下所示,并带有一个名为"engines"的子级:

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"
  }
}

此要求也反映在文档和默认项目中Firebase CLI创建的模板.

This requirement is also reflected in the documentation and the default project template created by the Firebase CLI.

如果您专门针对节点6,则会看到此警告消息:

If you specifically target node 6, you will see this warning message instead:

这篇关于Firebase CLI:"功能:警告!在PACKAGE.JSON中找不到引擎字段.默认为运行时的NODE6."的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 11:03