【发布时间】:2017-08-07 09:47:09
【问题描述】:
我在 heroku GET https://my-app.herokuapp.com/index.js 404 (Not Found) 中收到此错误
我的 Procfile 中有这个:web: npm start
然后在我的 package.json 我有"start": "node ./app/index.js"
我的根级别的应用程序文件夹包含一个index.js,其中包含:
var express = require('express');
var app = express();
app.use('/', express.static('public'));
app.get('/', function(req, res) {
res.sendFile(__dirname + '/index.html');
});
app.listen(process.env.PORT || 8080);
而我的webpack.config.js 文件包含:
var path = require('path');
const webpack = require('webpack')
module.exports = {
entry: './main.js',
output: {
path: path.resolve(__dirname, 'public'),
filename: 'index.js'
},
module: {
loaders: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel',
query: {
presets: ['es2015', 'react', 'stage-2']
}
},
{
test: /\.scss$/,
loaders: ["style-loader", "css-loader", "sass-loader"]
}
]
}
}
也许我需要将它指向我的 public/index.js 文件,但是当我这样做时它仍然无法识别它。
有什么想法吗?
【问题讨论】:
标签: javascript node.js heroku webpack