在Heroku上部署nextjs应用-错误状态H20

时间:2020-07-24 05:35:12

标签: reactjs heroku next.js

我是新来的反应者和nextjs。我设法在nextjs中开发了一个简单的网站,当我使用npm run build在本地系统中构建项目而没有任何错误时,它可以正常工作,然后我尝试在heroku的仪表板中进行部署,它显示构建成功并已部署,但是当我检查时使用给定链接的项目将显示应用程序错误。在我检查heroku日志后,它的显示Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch就是这样。通过检查有关此链接的一些线程,我设法重新启动了heroku,但没有使用仍然是同样的问题。另外,我通过更改package.json将端口从3000更改为5000。如果有人指出问题,它将非常有帮助。

  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start -p 5000"
  },

这是我的heroku日志

2020-07-24T05:14:15.020173+00:00 heroku[web.1]: Starting process with command `npm start`
2020-07-24T05:14:17.215400+00:00 app[web.1]:
2020-07-24T05:14:17.215416+00:00 app[web.1]: > abcapp@0.1.0 start /app
2020-07-24T05:14:17.215416+00:00 app[web.1]: > next start
2020-07-24T05:14:17.215416+00:00 app[web.1]:
2020-07-24T05:14:17.458010+00:00 app[web.1]: ready - started server on http://localhost:3000
2020-07-24T05:14:37.208072+00:00 heroku[router]: at=error code=H20 desc="App boot timeout" method=GET path="/" host=abcapp.herokuapp.com request_id=55de2c51-58d2-430d-883d-7a1bc05cecfc fwd="157.46.187.156" dyno= connect= service= status=503 bytes= protocol=https
2020-07-24T05:15:15.482693+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2020-07-24T05:15:15.502706+00:00 heroku[web.1]: Stopping process with SIGKILL
2020-07-24T05:15:15.584970+00:00 heroku[web.1]: Process exited with status 137
2020-07-24T05:15:15.629010+00:00 heroku[web.1]: State changed from starting to crashed
2020-07-24T05:15:17.145562+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=abcapp.herokuapp.com request_id=9e610deb-8e1e-4ca6-9e60-7516bc36cd92 fwd="157.46.187.156" dyno= connect= service= status=503 bytes= protocol=https

1 个答案:

答案 0 :(得分:1)

我已经通过更新package.json来解决此问题,如下所示。

  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start -p $PORT"
  },