Node.js Heroku无法获取/响应应用程序

Node.js Heroku无法获取/响应应用程序,node.js,reactjs,heroku,npm,yarnpkg,Node.js,Reactjs,Heroku,Npm,Yarnpkg,我正在使用React&NodeJS和纱线包装管理器。我的应用程序在本地运行良好。但当我上传到Heroku时,它说无法获取/ 加载资源失败:服务器响应状态为404(未找到) 我的webpack.config.prod.js文件如下所示 const JS_BUNDLE = 'bundle.js'; module.exports = function (paths, loaders, plugins) { return { output: { path: paths.d

我正在使用React&NodeJS和纱线包装管理器。我的应用程序在本地运行良好。但当我上传到Heroku时,它说无法获取/

加载资源失败:服务器响应状态为404(未找到)

我的webpack.config.prod.js文件如下所示

 const JS_BUNDLE   = 'bundle.js';

module.exports = function (paths, loaders, plugins) {
  return {
    output: {
      path: paths.dist,
      filename: JS_BUNDLE,
    },
    module: {
      rules: [
        loaders.style,
      ],
    },
    devtool: 'source-map',
    plugins: [
      plugins.loaderOptions({
        minimize: true,
      }),
      plugins.uglifyJs({
        output: {
          comments: false,
        },
        compress: {
          warnings: false,
          drop_console: true,
          dead_code: true,
          unused: true,
          conditionals: true,
                comparisons: true,
                sequences: true,
                evaluate: true,
                if_return: true,
                join_vars: true,
        },
      }),
      plugins.definePlugin,
      plugins.genHtml({
        filename: 'index.html',
        template: 'template.html',
      }),
    ],
  };
};
我相信它在package.json上运行Thread和我的脚本时不会创建index.html

"scripts": {
"watch-dev": "NODE_ENV=development webpack-dev-server --hot --inline",
"api": "PORT=3000 nodemon server.js",
"start": "node server.js"
}

Heroku原木

2017-11-09T09:31:46.907824+00:00 heroku[web.1]:状态从启动更改为启动

2017-11-09T09:31:48.165220+00:00应用程序[网站1]:GET/404139-55.164毫秒

2017-11-09T09:31:48.154963+00:00 heroku[路由器]:at=info method=GET path=“/”host=hksmetal.herokuapp.com请求_id=0692c07a-6f96-4708-8a74-30704fbad48e fwd=“213.247.123.26”dyno=web.1 connect=1ms服务=128ms状态=404字节=543协议=https


如果您有任何建议,请提前感谢

您需要添加到index.html的返回<代码>app.use(express.static(path.join(uu dirname,'build'))


app.get('*',function(req,res){res.sendFile(path.join(uu dirname+'/build/index.html'));}

您需要将返回添加到index.html<代码>app.use(express.static(path.join(uu dirname,'build'))


app.get('*',function(req,res){res.sendFile(path.join(uu dirname+'/build/index.html'));}

请发布应用程序heroku终端的日志。是!我的错误我已经添加了请发布应用程序heroku终端的日志…是的!我的错误我已经补充了