部署后 Heroku 出现应用程序错误

crg*_*g63 5 heroku node.js npm reactjs yarnpkg

成功部署我的应用程序后,我单击“打开应用程序”,然后看到此错误:

Application error
An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details. You can do this from the Heroku CLI with the command
heroku logs --tail
Run Code Online (Sandbox Code Playgroud)

链接有错误https://fcrg.herokuapp.com/

但它确实可以在本地主机中使用yarn dev cli正常工作

后端应用程序的 package.json :

{
  "name": "site-web-france",
  "version": "1.0.0",
  "scripts": {
    "start": "node server.js",
    "heroku-postbuild": "cd client && npm install && npm install --only=dev --no-shrinkwrap && npm run build",
    "client": "cd client && yarn start",
    "server": "nodemon server.js",
    "dev": "concurrently --kill-others-on-fail \"yarn server\" \"yarn client\"",
    "dev:server": "cd client && yarn build && cd .. && yarn start",
    "start": "node server.js",
    "heroku-postbuild": "cd client && npm install && npm install --only=dev --no-shrinkwrap && npm run build"
  },
  "dependencies": {
    "body-parser": "^1.18.3",
    "express": "^4.16.3",
    "mongodb": "^3.1.1",
    "mongoose": "^5.2.6",
    "react-scripts": "^1.1.4"
  },
  "devDependencies": {
    "concurrently": "^3.5.0"
  }
}
Run Code Online (Sandbox Code Playgroud)

我认为这个问题是因为“纱线”,你觉得呢?

随后教程: https://medium.freecodecamp.org/how-to-make-create-react-app-work-with-a-node-backend-api-7c5c48acb1b0

Aja*_*pta 3

确保应用程序端口不是编码的,例如:

app.listen(3000, ...)

它可能会导致 Heroku 出现问题。相反,尝试使用环境变量PORT

app.listen(process.env.PORT || 3000, ...)

希望能帮助到你!