【发布时间】:2018-09-01 10:04:20
【问题描述】:
我有一个今年早些时候创建的 Firebase 项目。它使用 Cloud Functions 在实时数据库上运行一些操作。
昨天,我了解了Callable Cloud Functions,所以我决定在我的应用程序中尝试一下,看看我是否应该更新我现有的函数。我创建了一个简单的 Cloud Function 用于测试目的:
exports.testCall = functions.https.onCall((data, context) =>{
console.log(context.auth.uid);
return {response:"This means success"};
});
但是当我尝试部署这个功能时,我得到了错误:
错误:解析函数触发器时出错。
TypeError:functions.https.onCall 不是函数 在对象。 (/tmp/fbfn_7614ijhDwX0NY98S/index.js:114:36) 在 Module._compile (module.js:649:30) 在 Object.Module._extensions..js (module.js:660:10) 在 Module.load (module.js:561:32) 在 tryModuleLoad (module.js:501:12) 在 Function.Module._load (module.js:493:3) 在 Module.require (module.js:593:17) 在要求(内部/module.js:11:18) 在 /usr/local/lib/node_modules/firebase-tools/lib/triggerParser.js:18:11 在对象。 (/usr/local/lib/node_modules/firebase-tools/lib/triggerParser.js:32:3)
我知道 Callable Cloud Functions 已在最新的 Firebase SDK 中引入,因此我尝试使用以下方法对其进行更新:
sudo npm install -g firebase-tools
但我还不能部署我的云功能。我也尝试了部分部署,如Firebase docs 所示,但没有成功。我在文档中遗漏了什么吗?
【问题讨论】:
-
可调用函数是在 firebase-functions 0.9.0 版本的节点 SDK 中引入的。 github.com/firebase/firebase-functions/releases/tag/v0.9.0
标签: firebase google-cloud-functions firebase-tools firebase-cli