【问题标题】:How to deploy a nodejs app with module.exports on Firebase如何在 Firebase 上使用 module.exports 部署 nodejs 应用程序
【发布时间】:2020-12-05 04:58:41
【问题描述】:

我正在为我的 slack 机器人使用 node js 和 yarn。它在本地工作正常,但我不知道如何在 firebase 上部署它以让我的机器人工作。 这是我的 index.js:

const functions = require('firebase-functions');
require = require("esm")(module/*, options */);
module.exports = require("./app.js");

但要将其部署在 firebase 上,我需要类似我的 index.js 的东西:

    const app = express();
    exports.widgets = functions.https.onRequest(app);

但我没有使用 express()。那么我该怎么做呢?附言我所有的机器人逻辑都在 app.js 中,这就是为什么我 require("./app.js");

【问题讨论】:

  • 这里没有足够的信息来了解您需要做什么。我建议查看 HTTP 触发器的文档以了解如何编写和部署函数。如果您不使用 express,则必须学习其他替代方法。 firebase.google.com/docs/functions/http-events

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


【解决方案1】:

您可以使用 Firebase 托管进行部署:https://firebase.google.com/docs/hosting/deploying。它非常易于使用。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-10-09
    • 2019-10-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多