使用Inline-Editor的Firebase部署错误

时间:2017-09-15 09:55:59

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

我正在尝试使用以下代码设置简单的Google云端功能:

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,虽然我甚至没有使用它们,但我使用的是Inline-Editor。我该怎么办?

1 个答案:

答案 0 :(得分:1)

我想出了如何解决这个错误。我已经从Firebase CLI部署了一些云功能。当我尝试从Web界面创建一个新的时,错误就抛出了。显然,您只能使用相同类型的CLI协同工作的云功能,您无法将它们组合在一起。要修复错误,我必须使用控制台重新部署它们。