我正在尝试将我的MEAN堆栈应用程序部署到heroku。我已成功提交了该应用程序,但似乎无法将ng build“ dist”文件连接到server.js文件。
这是我尝试添加文件的server.js代码:
var distDir = __dirname + "/dist/";
app.use(express.static(distDir));
答案 0 :(得分:0)
尝试一下:
@PersistenceContext
const path = require('path');
const express = require('express');
const app = express();
// Serve static files
app.use(express.static(__dirname + '/outputPath'));
// Send all requests to index.html
app.get('/*', function(req, res) {
res.sendFile(path.join(__dirname + '/outputPath/index.html'));
});
// default Heroku port
app.listen(process.env.PORT || 5000)
是outputPath
在outputPath
文件中的值(项目->架构师->构建->选项-> outputPath)。