【发布时间】:2019-10-04 11:49:27
【问题描述】:
您好,我想在节点服务器上使用express 运行我的应用程序。
我的 server.js :
var express = require('express');
var path = require('path');
var app = express();
app.get('/', (req, res) => {
res.sendFile(path.resolve('dist/my-app/index.html'))
});
app.listen(80, () => {
console.log('Server started!')
})
但是当我试图在localhost 上查看我的网站时。什么都没有出现。你能帮帮我吗?
【问题讨论】:
-
(1) 您在
res.sendFile(path.resolve('dist/my-app/index.html'))处收到任何错误... (2) 当您在浏览器中执行localhost:[80]/时,您看到了什么? (3) 尝试将您的 app.listen 的端口更改为 8080 而不是 80