Firebase 部署功能未部署
Firebase deploy functions doesn't deploy
我正在为我的新项目学习 firebase,我需要部署 1 个函数,当我 运行 firebase deploy --only functions:updateDatabase
我在终端中得到这个输出:
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!
但是函数没有部署。我试图重新安装节点模块,npm i。我可以在 firebase 上访问项目本身,但无法弄清楚为什么 tihs 函数没有部署并且没有错误消息。非常感谢任何帮助和建议。
根据上述问题,该问题的根本原因可能是您没有正确导出函数。正确导出函数并部署。请参阅下面的示例代码。
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
这会部署,因为函数导出正确。
但是,通过部署如下函数:
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!");
};
结果为:
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!
因此,该功能未正确部署。
您可以查看 Get started: write, test, and deploy your first functions 了解更多信息。
我正在为我的新项目学习 firebase,我需要部署 1 个函数,当我 运行 firebase deploy --only functions:updateDatabase
我在终端中得到这个输出:
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!
但是函数没有部署。我试图重新安装节点模块,npm i。我可以在 firebase 上访问项目本身,但无法弄清楚为什么 tihs 函数没有部署并且没有错误消息。非常感谢任何帮助和建议。
根据上述问题,该问题的根本原因可能是您没有正确导出函数。正确导出函数并部署。请参阅下面的示例代码。
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
这会部署,因为函数导出正确。
但是,通过部署如下函数:
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!");
};
结果为:
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!
因此,该功能未正确部署。
您可以查看 Get started: write, test, and deploy your first functions 了解更多信息。