【问题标题】:Functions Deployement Error Firebase函数部署错误 Firebase
【发布时间】:2018-09-13 06:33:06
【问题描述】:

我正在尝试在 firebase 函数上发布简单代码,但每次都会产生错误

errors
functions: Finished running predeploy script.
i  functions: ensuring necessary APIs are enabled...
✔  functions: all necessary APIs are enabled
i  functions: preparing functions directory for uploading...
i  functions: packaged functions (53.73 KB) for uploading
✔  functions: functions folder uploaded successfully
i  functions: updating function sendNotification...
⚠  functions[sendNotification]: Deployment error.
Error setting up the execution environment for your function. Please 
try again after a few minutes.


 Functions deploy had errors. To continue deploying other features (such as database), run:
  firebase deploy --except functions

Error: Functions did not deploy properly. 

我尝试部署的代码是

'use strict'

const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);




exports.sendNotification = functions.database.ref('/notifications/{user_id}/{notification_id}').onWrite(event => {




 const user_id = event.params.user_id;
 const notification_id = event.params.notification_id;

 console.log('We have a notification from : ', user_id);

 });

面对这个错误大约 2 天,尝试堆栈和其他论坛上提供的所有答案,但可以找到任何人都可以在此帮助我的任何解决方案

【问题讨论】:

标签: android firebase google-cloud-functions


【解决方案1】:

您应该让您的函数返回值、null 或承诺。除此之外,我看不出有什么不妥。您似乎收到的错误可能是您这边的连接问题,或者(奇怪)Google Firebase 方面的问题。

同时尝试更新您的 firebase 工具

npm install -g firebase-tools

啊,考虑一下这里的更新,因为云功能不再处于测试阶段: https://firebase.googleblog.com/2018/04/launching-cloud-functions-for-firebase-1-0.html?utm_source=email&utm_medium=email&utm_campaign=cloud_functions_v1.0

【讨论】:

  • 它的意思是正确部署它我必须对功能进行大的改变
  • 您能告诉我们:您使用什么命令进行部署?你的机器上有什么版本的nodeJS?并更新您在控制台上获得的全部输出?另请查看:stackoverflow.com/q/48060153/5982279
  • 我们需要更多信息,我知道您正在使用 deploy 命令,但您是否发送任何参数?像 --only 函数?你有什么版本的nodejs?看是否兼容云功能。以前可以部署吗?您的控制台上的全部输出是什么?有人建议联系 Firebase 支持,但您仍需要提供所有这些信息...
  • 我联系了他们,但什么也没发生
  • 6.11.1 node js version as on stack有人告诉我函数只能在这个版本上工作,但这对我也没有帮助
猜你喜欢
  • 2017-12-12
  • 2021-04-10
  • 2018-08-04
  • 2021-05-06
  • 2022-08-21
  • 2022-01-09
  • 1970-01-01
  • 2017-10-15
  • 2021-09-22
相关资源
最近更新 更多