如何修复Gatsby JS上的错误R10(启动超时)?

时间:2019-10-25 04:57:51

标签: node.js heroku gatsby

我想在Heroku上设置Gatsby。我已经按照https://www.gatsbyjs.org/docs/deploying-to-heroku/的步骤进行操作,并按照此处https://devcenter.heroku.com/articles/procfile的说明创建了一个Procfile,但是部署时仍然出现超时错误。该端口似乎开始工作,但是由于某种原因它停止了。

我尝试过将不同的行放入Procfile中,但没有一个起作用。目前,我有web: gatsby serve --port $PORT-这是我尝试放入此文件的最后一件事。我还尝试了web: npm start -- --port $PORT和其他可以轻松搜索的选项。

2019-10-24T23:06:52.707649+00:00 app[web.1]: 
2019-10-24T23:07:49.930330+00:00 heroku[web.1]: State changed from starting to crashed
2019-10-24T23:07:49.832843+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2019-10-24T23:07:49.832843+00:00 heroku[web.1]: Stopping process with SIGKILL
2019-10-24T23:07:49.910127+00:00 heroku[web.1]: Process exited with status 137
Disconnected from log stream. There may be events happening that you do not see here! Attempting to reconnect...
2019-10-24T23:06:52.444262+00:00 app[web.1]: ║   To learn more, checkout https://gatsby.dev/telemetry                 ║
2019-10-24T23:06:52.444263+00:00 app[web.1]: ║                                                                        ║
2019-10-24T23:06:52.444264+00:00 app[web.1]: ╚════════════════════════════════════════════════════════════════════════╝
2019-10-24T23:06:52.445563+00:00 app[web.1]: 
2019-10-24T23:06:52.707515+00:00 app[web.1]: [2K[1A[2K[Ginfo gatsby serve running at: http://localhost:4563/
2019-10-24T23:06:52.707649+00:00 app[web.1]: 
2019-10-24T23:07:49.930330+00:00 heroku[web.1]: State changed from starting to crashed
2019-10-24T23:07:49.832843+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2019-10-24T23:07:49.832843+00:00 heroku[web.1]: Stopping process with SIGKILL
2019-10-24T23:07:49.910127+00:00 heroku[web.1]: Process exited with status 137

有什么主意我该如何运作?

1 个答案:

答案 0 :(得分:0)

您可能要使用gatsby build而不是gatsby serve,因为后者用于本地测试。 gatsby build将为您提供静态资产并优化速度。尝试删除Procfile,然后Heroku应该在package.json中捕获build命令。