将我的Web应用程序(react和node / express)部署到heroku会给我带来很多错误

时间:2018-10-26 19:31:25

标签: node.js reactjs heroku

这就是我放入node.js / express.js的内容

const port = process.env.PORT || 2000;

app.listen(port, () => {
console.log("App is running on port " + port);
});

if(process.env.NODE_ENV === 'production'){
//set static folder
app.use(express.static('cr-follow-up/build'));

app.get('*', (req, res) => {
    const index = path.join(__dirname, 'build', 'index.html');
    res.sendFile(index);
})
}

这就是我在我的index.js文件中的package.json文件中添加的节点/表达式

"heroku-postbuild": "NPM_CONFIG_PRODUCTION=false npm install --prefix cr- 
follow-up && npm run build --prefix cr-follow-up"

enter image description here enter image description here

0 个答案:

没有答案