【问题标题】:Firebase deployment error using Inline-Editor使用内联编辑器的 Firebase 部署错误
【发布时间】:2017-10-03 17:45:45
【问题描述】:

我正在尝试使用以下代码设置一个简单的 Google Cloud Function:

index.js:

var functions = require('firebase-functions');
exports.updateLastMessage = functions.database.ref("/messages/{chatID}/{messageID}").onWrite(event => {
  console.log("New Message received")
})

package.json:

{
  "name": "updateLastMessage",
  "version": "0.0.2",
  "dependencies": {
    "firebase-functions": "^0.5.1",
    "actions-on-google": "^1.0.7",
    "firebase-admin": "^4.0.5"
  }
}

当我尝试部署它时,我收到以下错误:

Function load error: Code in file index.js can't be loaded.
Is there a syntax error in your code?
Detailed stack trace: Error: Firebase config variables are not available. Please use the latest version of the Firebase CLI to deploy this function.
    at init (/user_code/node_modules/firebase-functions/lib/config.js:51:15)
    at Object.config (/user_code/node_modules/firebase-functions/lib/config.js:29:9)
    at Object.ref (/user_code/node_modules/firebase-functions/lib/providers/database.js:58:31)
    at Object.<anonymous> (/user_code/index.js:3:48)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)

它告诉我更新 Firebase CLI,虽然我什至没有使用它们,但我正在使用内联编辑器。我该怎么办?

【问题讨论】:

  • 要部署您运行的代码 firebase deploy,这是对 Firebase CLI 的调用。我将专注于“您的代码中是否存在语法错误?”位。
  • @FrankvanPuffelen 不,我不使用 Firebase CLI,我使用在线版本。而且我没有发现语法错误,即使必须有一个。
  • 你指的是哪个在线版本?我不知道 Firebase 上的 Cloud Functions 有任何在线编辑器。能否提供链接或截图?
  • 啊...我永远无法成功地编辑 Firebase 部署的功能代码。对不起,我不能再有用了。

标签: javascript node.js firebase google-cloud-functions


【解决方案1】:

我想出了如何解决这个错误。我已经从 Firebase CLI 部署了一些云功能。当我尝试从 Web 界面创建一个新界面时,出现了错误。显然,您只能通过相同类型的 CLI 让 Cloud Functions 一起工作,而不能将它们组合起来。为了修复错误,我不得不使用控制台重新部署它们。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-08-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-14
    • 1970-01-01
    • 2012-05-30
    相关资源
    最近更新 更多