如何在Firebase上使用module.exports部署Node.js应用

问题描述

我正在为松散的bot使用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");

的原因

解决方法

您可以使用Firebase托管进行部署:https://firebase.google.com/docs/hosting/deploying。这很容易使用。