【问题标题】:Firebase functions stopped workingFirebase 功能停止工作
【发布时间】:2017-11-20 22:34:15
【问题描述】:

详细的堆栈跟踪:错误:找不到模块“firebase-functions”

我有一个正在运行的项目。现在,当我尝试部署时,它失败了。我已经从函数文件夹中运行了`npm i。我的包中有“firebase-functions”。我已经删除了包锁,然后重新安装。我已删除 firebase-functions 和 firebase-admin 并重新添加。

我们在生产中使用它,所以当我推动 firebase 进行一个简单的测试项目时,这非常令人沮丧。

非常困惑。谢谢。

【问题讨论】:

  • 另外当我去谷歌云平台查看部署的代码时,似乎是一个旧版本。我可以删除该函数,然后重新应用,但我的代码的旧版本似乎已部署,这很奇怪。

标签: firebase google-cloud-functions


【解决方案1】:

在你的项目中你应该有这样的结构:

myproject
 +- .firebaserc    # Hidden file that helps you quickly switch between
 |                 # projects with `firebase use`
 |
 +- firebase.json  # Describes properties for your project
 |
 +- functions/     # Directory containing all your functions code
      |
      +- package.json  # npm package file describing your Cloud Functions code
      |
      +- index.js      # main source file for your Cloud Functions code
      |
      +- node_modules/ # directory where your dependencies (declared in
                   # package.json) are installed

您收到此错误:

错误:找不到模块“firebase-functions”

表示模块firebase-functions 不在node-modules 文件夹中。那可能是因为您将它移到了另一个地方,但它需要在您的项目结构中的 node-module

【讨论】:

  • 感谢您的回复,但这是我的结构,是的,该文件夹存在于 node_modules 函数中。这行得通。我已经部署了很多次,只是今天失败了。另外,如果我部署某些东西但它失败了,以前的版本不应该仍然有效吗?这是一个非常糟糕的部署过程,不是吗?
  • 不管怎样,在本地运行 firebase serve --only functions 可以正常工作。
  • 在您的 package-json 中是否有 firebase-functions 依赖项,您是否在 package-json 中的脚本中有此 "deploy": "firebase deploy --only functions",
  • 我在函数文件夹中的 package.json 中有 firebase-functions,但我没有那个脚本部分。那是新的吗?服务器端的firebase需要吗?但是,添加它没有任何区别。那是我用来部署的代码。哎呀做错了。现在试试....
  • 这太奇怪了。是的,那行得通。运行 npm run deploy 有效,但运行 firebase deploy --only functions 无效。我想这是全球火力基地与本地的版本差异?不知道。非常感谢!!!
猜你喜欢
  • 1970-01-01
  • 2021-10-16
  • 1970-01-01
  • 2017-10-29
  • 2018-08-25
  • 2021-01-29
  • 2020-08-15
  • 1970-01-01
相关资源
最近更新 更多