托管node.js不工作的Angular 4应用程序
我正在尝试使用Node.js托管Angular 4应用程序托管node.js不工作的Angular 4应用程序,node.js,angular,express,Node.js,Angular,Express,我正在尝试使用Node.js托管Angular 4应用程序 我遵循以下指南: 然而,当我启动node.js服务器时,它只是继续加载,不显示任何页面。 文件夹布局: -距离 --资产 --app.js --index.html --inline.xxx.bundle.js --main.xxx.bundle.js --polyfills.xxx.bundle.js --styles.xxx.bundle.css --vendor.xxx.bundle.js app.js的内容包括: var exp
我遵循以下指南:
然而,当我启动node.js服务器时,它只是继续加载,不显示任何页面。 文件夹布局:
-距离
--资产
--app.js
--index.html
--inline.xxx.bundle.js
--main.xxx.bundle.js
--polyfills.xxx.bundle.js
--styles.xxx.bundle.css
--vendor.xxx.bundle.js
app.js的内容包括:
var express = require('express');
var path = require('path');
var bodyParser = require('body-parser');
var logger = require('morgan');
var app = express();
app.use(logger('dev'));
app.use(bodyParser.json);
app.use(bodyParser.urlencoded({ extended: false }));
app.use(express.static(__dirname));
app.get('/*', function (req, res) {
res.sendFile(path.join(__dirname, 'index.html'));
});
app.use(function(req, res, next) {
var err = new Error('Not Found');
err.status = 404;
next(err);
});
var port = process.env.PORT || 8080;
app.listen(port, function () {
console.log('Server running at port ' + port);
});
module.exports = app;
我从以下几点开始:
node dist/app.js
编辑:我现在让它工作了。不确定这是否正确:
var express = require('express');
var app = express();
var path = require('path');
app.use(express.static(path.join(__dirname, '/dist')));
app.get('/*', function(req, res) {
res.
sendFile(path.join(__dirname + '/dist/index.html'));
});
app.listen(8080, function () {
console.log('App started');
});
最终它以这种方式工作:
var express = require('express');
var app = express();
var path = require('path');
app.use(express.static(path.join(__dirname, '/dist')));
app.get('/*', function(req, res) {
res.
sendFile(path.join(__dirname + '/dist/index.html'));
});
app.listen(8080, function () {
console.log('App started');
});
粘贴你的索引。HTMLID你找到这个问题的解决方案了吗?@ContinuousError它在我问题的底部。