Cloud Functions模拟器需要安装模块“ firebase-admin”

Leo*_*Leo 9 firebase google-cloud-functions firebase-admin

继续尝试重新开始firebase serve工作。我只是问了这个问题(得到了很好的答复,谢谢): npm ERR!对等部门丢失:firebase-admin @ ^ 7.0.0,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)
Run Code Online (Sandbox Code Playgroud)

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

Nic*_*rth 6

我看到的是同一件事,看来您可以将Firebase-tools版本降级为6.8.0

npm install firebase-tools@6.8.0 -g

(我已经尝试过了,并且有效)


M.L*_*wis 5

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

我不知道答案到底是什么,但是开始四处查看节点版本。

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

// functions/package.json

{
  "name": ...,
  "scripts": ...,
  "dependencies": ...,
  
  "engines": {
    "node": "10"
  }
 
}
Run Code Online (Sandbox Code Playgroud)

请注意,Node 10仍在Firebase上处于beta版。

希望这可以帮助您正确解决问题。

  • 设置`“ node”:“ 8”`也可以。 (2认同)
  • 谢谢。我已经安装了 `nvm`,现在使用的是版本 8。我已经更改为 `"node": "8"`。我已经删除了 `package-lock.json` 和 `node_modules` 并运行了 `npm install`。我仍然遇到同样的错误。 (2认同)