简体   繁体   English

Firebase 部署功能未部署

[英]Firebase deploy functions doesn't deploy

I'm learning firebase for my new project, I need to deploy 1 function and when I run firebase deploy --only functions:updateDatabase I get this output in the terminal:我正在为我的新项目学习 firebase,我需要部署 1 function,当我运行firebase deploy --only functions:updateDatabase我在终端中得到这个 output:

deploying functions
i  functions: ensuring required API cloudfunctions.googleapis.com is enabled...
i  functions: ensuring required API cloudbuild.googleapis.com is enabled...
+  functions: required API cloudfunctions.googleapis.com is enabled
+  functions: required API cloudbuild.googleapis.com is enabled
i  functions: preparing functions directory for uploading...
i  functions: packaged functions (75 KB) for uploading
+  functions: functions folder uploaded successfully
i  functions: cleaning up build files...

+  Deploy complete!

but the function is not deployed.但 function 未部署。 I tried to reinstall node-modules, npm i.我试图重新安装节点模块,npm i。 I have access to the project itself on the firebase, but can't figure out why tihs function is not deploying and there is no error message.我可以访问 firebase 上的项目本身,但无法弄清楚为什么 tihs function 没有部署并且没有错误消息。 Any help and advise is greatly appreciated.非常感谢任何帮助和建议。

Based on the question above, The possible root cause for this issue is you didn't export the functions properly.根据上面的问题,这个问题的根本原因可能是你没有正确导出函数。 Properly export the function and deploy.正确导出 function 并部署。 See example code below.请参阅下面的示例代码。

const functions = require("firebase-functions");

// Create and Deploy Your First Cloud Functions
// https://firebase.google.com/docs/functions/write-firebase-functions

exports.helloWorld = functions.https.onRequest((request, response) => {
  functions.logger.info("Hello logs!", {structuredData: true});
  response.send("Hello from Firebase!");
});
firebase deploy --only functions:helloWorld

This would deploy because the function is exported properly.这将部署,因为 function 已正确导出。

However, by deploying a function like below:但是,通过部署如下所示的 function:

const functions = require("firebase-functions");

// Create and Deploy Your First Cloud Functions
// https://firebase.google.com/docs/functions/write-firebase-functions

function helloWorld() {
  functions.logger.info("Hello logs!", {structuredData: true});
  response.send("Hello from Firebase!");
};

will result to:将导致:

i  deploying functions
i  functions: ensuring required API cloudfunctions.googleapis.com is enabled...
i  functions: ensuring required API cloudbuild.googleapis.com is enabled...
✔  functions: required API cloudfunctions.googleapis.com is enabled
✔  functions: required API cloudbuild.googleapis.com is enabled
i  functions: cleaning up build files...

✔  Deploy complete!

Thus, the function is not properly deployed.因此,function 未正确部署。

You may check Get started: write, test, and deploy your first functions for more information.您可以查看入门:编写、测试和部署您的第一个函数以获取更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM