【问题标题】:Azure deployment of node app not working with exports.节点应用程序的 Azure 部署不适用于导出。
【发布时间】:2014-09-02 14:04:43
【问题描述】:

我正在尝试在 azure 上部署一个简单的应用程序,该应用程序需要名字和姓氏。我已经使用 express 搭建了脚手架,由于某种原因,当我尝试访问它时网页是空白的。

我想我已经找到了问题的一部分(我使用的示例代码来自默认的 express 应用程序),其中 express 生成的默认代码在 index.js 路由文件中使用:

/* GET home page. */
router.get('/', function(req, res) {
  res.render('index', { title: 'Express' });
});

module.exports = router;

但我已将其更改为单独的导出,使其看起来更像这样。

exports.index = router;

我还对 app.js 进行了适当的修改,使其看起来像这样:

app.use('/', routes).index;
app.use('/users', users);

修改后的应用程序在本地运行,但是一旦我部署它,页面就显示为空白。有谁知道为什么?感谢您的阅读。

【问题讨论】:

    标签: node.js azure deployment express


    【解决方案1】:
    app.use('/', routes).index;
    

    应该是:

    app.use('/', routes.index);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-05-03
      • 1970-01-01
      • 2015-12-06
      • 2020-01-17
      • 1970-01-01
      • 2016-04-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多