【问题标题】:The Cloud Functions emulator requires the module "firebase-admin" to be installedCloud Functions 模拟器需要安装模块“firebase-admin”
【发布时间】:2019-09-27 19:56:01
【问题描述】:

继续尝试让firebase serve 再次工作。我刚刚问了这个问题(得到了很好的答复,谢谢): npm ERR! peer dep missing: firebase-admin@^7.0.0, required by firebase-functions@2.3.1

在执行npm list firebase-admin 时,我现在看到了预期的输出-- firebase-admin@7.3.0。

但是firebase serve 仍然不起作用。我明白了:

!  Your requested "node" version "6" doesn't match your global version "10"
...
!  The Cloud Functions emulator requires the module "firebase-admin" to be installed. This package is in your package.json, but it's not available. You probably need to run "npm install" in your functions directory.
i  functions: Your functions could not be parsed due to an issue with your node_modules (see above)

所以firebase serve 仍然看不到firebase-admin 模块。到底是怎么回事?我该怎么办?

【问题讨论】:

标签: firebase google-cloud-functions firebase-admin


【解决方案1】:

现在看来这个问题与您在本地安装的 Node 版本有关。

我不知道我脑海中的答案,但开始查看节点版本。

在您的 functions/package.json 中 - 您可能需要指定要使用的节点版本 (https://firebase.google.com/docs/functions/manage-functions):

// functions/package.json

{
  "name": ...,
  "scripts": ...,
  "dependencies": ...,
  
  "engines": {
    "node": "10"
  }
 
}

请注意,Node 10 在 Firebase 上仍处于测试阶段。

【讨论】:

  • 设置"node": "8" 也可能是一个选项。
  • 谢谢。我已经安装了nvm,现在使用的是版本 8。我已更改为"node": "8"。我已删除 package-lock.json 和 node_modules 并运行 npm install。我仍然遇到同样的错误。
【解决方案2】:

我看到了同样的东西,看起来你可以downgrade your firebase-tools version to 6.8.0

npm install firebase-tools@6.8.0 -g

(我试过了,效果很好)

【讨论】:

  • 谢谢,这行得通。它也解决了我在这里报告的问题:stackoverflow.com/questions/56026747/…
  • 这对我不起作用。模拟器点击部署到 firebase 的函数,而不是从 localhost 提供它。
【解决方案3】:

基本上,这意味着您应该降级到节点 6 或节点 8,而不是 升级到 10(因为您系统中的节点版本是 10,而 Firebase 请求版本 6)。 Firebase 尚不支持 Node 10+,甚至不支持最新版本 12.15.0

【讨论】:

【解决方案4】:

打开终端并进入您的 /myProject/functions 文件夹。

然后,运行npm install

所有必要的模块都应该出现在 node_modules 文件夹中。

【讨论】:

    【解决方案5】:

    删除node_module 文件夹。 在包含package.json 的目录中再次运行npm install。 这解决了我的问题。

    【讨论】:

      猜你喜欢
      • 2019-10-19
      • 2018-09-10
      • 1970-01-01
      • 1970-01-01
      • 2021-12-03
      • 2017-03-04
      • 1970-01-01
      • 2019-02-12
      • 1970-01-01
      相关资源
      最近更新 更多