【问题标题】:Unable to host my React Hasura GraphQL app on Heroku无法在 Heroku 上托管我的 React Hasura GraphQL 应用程序
【发布时间】:2021-02-24 05:20:36
【问题描述】:

我使用 Hasura GraphQL API 和 React 创建了一个简单的日程管理应用程序。我试图通过 github 存储库与它链接来在 Heroku 上托管我的应用程序,但是它不能正常工作。我是第一次使用 Heroku 和 GraphQL,所以我无法弄清楚我到底做错了什么。

我的 Github 存储库链接来自我的源代码:https://github.com/yash-sethia/Schedule-Management-App-using-GraphQL-and-React

我的 heroku 应用链接(该节目是错误屏幕):https://schedule-management-app.herokuapp.com/

这是日志中显示的错误消息:

    2020-11-11T04:57:35.434926+00:00 heroku[web.1]: State changed from starting to crashed
2020-11-11T08:14:26.702564+00:00 heroku[web.1]: State changed from crashed to starting
2020-11-11T08:14:44.659544+00:00 heroku[web.1]: Starting process with command `npm start`
2020-11-11T08:14:47.483996+00:00 app[web.1]:
2020-11-11T08:14:47.484007+00:00 app[web.1]: > webd_project@0.1.0 start /app
2020-11-11T08:14:47.484007+00:00 app[web.1]: > react-scripts start
2020-11-11T08:14:47.484008+00:00 app[web.1]:
2020-11-11T08:14:50.665030+00:00 app[web.1]: ℹ 「wds」: Project is running at http://172.18.243.110/
2020-11-11T08:14:50.665788+00:00 app[web.1]: ℹ 「wds」: webpack output is served from
2020-11-11T08:14:50.665967+00:00 app[web.1]: ℹ 「wds」: Content not from webpack is served from /app/public
2020-11-11T08:14:50.666129+00:00 app[web.1]: ℹ 「wds」: 404s will fallback to /
2020-11-11T08:14:50.666503+00:00 app[web.1]: Starting the development server...
2020-11-11T08:14:50.666504+00:00 app[web.1]:
2020-11-11T08:14:50.778105+00:00 heroku[web.1]: Process exited with status 0
2020-11-11T08:14:51.016955+00:00 heroku[web.1]: State changed from starting to crashed
2020-11-11T13:52:48.230487+00:00 heroku[web.1]: State changed from crashed to starting
2020-11-11T13:52:59.344712+00:00 heroku[web.1]: Starting process with command `npm start`
2020-11-11T13:53:01.550816+00:00 app[web.1]:
2020-11-11T13:53:01.550849+00:00 app[web.1]: > webd_project@0.1.0 start /app
2020-11-11T13:53:01.550850+00:00 app[web.1]: > react-scripts start
2020-11-11T13:53:01.550850+00:00 app[web.1]:
2020-11-11T13:53:03.757281+00:00 app[web.1]: ℹ 「wds」: Project is running at http://172.19.87.134/
2020-11-11T13:53:03.757641+00:00 app[web.1]: ℹ 「wds」: webpack output is served from
2020-11-11T13:53:03.757738+00:00 app[web.1]: ℹ 「wds」: Content not from webpack is served from /app/public
2020-11-11T13:53:03.757806+00:00 app[web.1]: ℹ 「wds」: 404s will fallback to /
2020-11-11T13:53:03.757993+00:00 app[web.1]: Starting the development server...
2020-11-11T13:53:03.757994+00:00 app[web.1]:
2020-11-11T13:53:03.852308+00:00 heroku[web.1]: Process exited with status 0
2020-11-11T13:53:03.892089+00:00 heroku[web.1]: State changed from starting to crashed
2020-11-11T19:28:16.774146+00:00 heroku[web.1]: State changed from crashed to starting
2020-11-11T19:28:34.737934+00:00 heroku[web.1]: Starting process with command `npm start`
2020-11-11T19:28:37.269259+00:00 app[web.1]:
2020-11-11T19:28:37.269283+00:00 app[web.1]: > webd_project@0.1.0 start /app
2020-11-11T19:28:37.269283+00:00 app[web.1]: > react-scripts start
2020-11-11T19:28:37.269284+00:00 app[web.1]:
2020-11-11T19:28:39.241913+00:00 app[web.1]: ℹ 「wds」: Project is running at http://172.16.104.210/
2020-11-11T19:28:39.242274+00:00 app[web.1]: ℹ 「wds」: webpack output is served from
2020-11-11T19:28:39.242349+00:00 app[web.1]: ℹ 「wds」: Content not from webpack is served from /app/public
2020-11-11T19:28:39.242427+00:00 app[web.1]: ℹ 「wds」: 404s will fallback to /
2020-11-11T19:28:39.242585+00:00 app[web.1]: Starting the development server...
2020-11-11T19:28:39.242586+00:00 app[web.1]:
2020-11-11T19:28:39.306313+00:00 heroku[web.1]: Process exited with status 0
2020-11-11T19:28:39.339563+00:00 heroku[web.1]: State changed from starting to crashed
2020-11-12T01:20:50.986428+00:00 heroku[web.1]: State changed from crashed to starting
2020-11-12T01:21:04.061714+00:00 heroku[web.1]: Starting process with command `npm start`
2020-11-12T01:21:07.918791+00:00 app[web.1]:
2020-11-12T01:21:07.918811+00:00 app[web.1]: > webd_project@0.1.0 start /app
2020-11-12T01:21:07.918812+00:00 app[web.1]: > react-scripts start
2020-11-12T01:21:07.918812+00:00 app[web.1]:
2020-11-12T01:21:11.178494+00:00 app[web.1]: ℹ 「wds」: Project is running at http://172.18.192.242/
2020-11-12T01:21:11.178876+00:00 app[web.1]: ℹ 「wds」: webpack output is served from
2020-11-12T01:21:11.178944+00:00 app[web.1]: ℹ 「wds」: Content not from webpack is served from /app/public
2020-11-12T01:21:11.179026+00:00 app[web.1]: ℹ 「wds」: 404s will fallback to /
2020-11-12T01:21:11.179232+00:00 app[web.1]: Starting the development server...
2020-11-12T01:21:11.179234+00:00 app[web.1]:
2020-11-12T01:21:11.269635+00:00 heroku[web.1]: Process exited with status 0
2020-11-12T01:21:11.325157+00:00 heroku[web.1]: State changed from starting to crashed
2020-11-12T06:57:29.079557+00:00 heroku[web.1]: State changed from crashed to starting
2020-11-12T06:57:41.430648+00:00 heroku[web.1]: Starting process with command `npm start`
2020-11-12T06:57:44.032930+00:00 app[web.1]:
2020-11-12T06:57:44.032950+00:00 app[web.1]: > webd_project@0.1.0 start /app
2020-11-12T06:57:44.032950+00:00 app[web.1]: > react-scripts start
2020-11-12T06:57:44.032951+00:00 app[web.1]:
2020-11-12T06:57:46.396411+00:00 app[web.1]: ℹ 「wds」: Project is running at http://172.18.237.234/
2020-11-12T06:57:46.396697+00:00 app[web.1]: ℹ 「wds」: webpack output is served from
2020-11-12T06:57:46.396777+00:00 app[web.1]: ℹ 「wds」: Content not from webpack is served from /app/public
2020-11-12T06:57:46.396841+00:00 app[web.1]: ℹ 「wds」: 404s will fallback to /
2020-11-12T06:57:46.397012+00:00 app[web.1]: Starting the development server...
2020-11-12T06:57:46.397013+00:00 app[web.1]:
2020-11-12T06:57:46.473000+00:00 heroku[web.1]: Process exited with status 0
2020-11-12T06:57:46.511649+00:00 heroku[web.1]: State changed from starting to crashed
2020-11-12T07:38:08.135193+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=schedule-management-app.herokuapp.com request_id=64916495-a682-4895-8725-0a876ca78165 fwd="182.64.168.27" dyno= connect= service= status=503 bytes= protocol=https
2020-11-12T07:38:08.892960+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=schedule-management-app.herokuapp.com request_id=8efbff92-a5f9-401a-ae7b-5afb620fc95b fwd="182.64.168.27" dyno= connect= service= status=503 bytes= protocol=https
2020-11-12T07:39:14.552520+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=schedule-management-app.herokuapp.com request_id=622ae611-b44e-4738-9987-fa7f2077ceca fwd="182.64.168.27" dyno= connect= service= status=503 bytes= protocol=https
2020-11-12T07:39:15.245006+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=schedule-management-app.herokuapp.com request_id=740f836f-6c7c-4a71-8069-e3ce75dd8e88 fwd="182.64.168.27" dyno= connect= service= status=503 bytes= protocol=https
2020-11-12T07:40:41.931479+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=schedule-management-app.herokuapp.com request_id=c1b7dbbd-ef85-4433-b330-ef5e08d27467 fwd="182.64.168.27" dyno= connect= service= status=503 bytes= protocol=https
2020-11-12T07:40:42.807842+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=schedule-management-app.herokuapp.com request_id=f471954f-6720-450b-a3a7-f8d3448ab11e fwd="182.64.168.27" dyno= connect= service= status=503 bytes= protocol=https
2020-11-12T07:51:39.028875+00:00 app[api]: Starting process with command `heroku logs --tail` by user yyashsethia@gmail.com
2020-11-12T07:51:55.700302+00:00 heroku[run.4516]: State changed from starting to up
2020-11-12T07:51:56.076838+00:00 heroku[run.4516]: Awaiting client
2020-11-12T07:51:56.130401+00:00 heroku[run.4516]: Starting process with command `heroku logs --tail`
2020-11-12T07:52:01.025743+00:00 heroku[run.4516]: Process exited with status 127
2020-11-12T07:52:01.069575+00:00 heroku[run.4516]: State changed from up to complete
2020-11-12T07:52:12.830669+00:00 app[api]: Starting process with command `logs --tail` by user yyashsethia@gmail.com
2020-11-12T07:52:29.374524+00:00 heroku[run.2810]: Awaiting client
2020-11-12T07:52:29.402908+00:00 heroku[run.2810]: Starting process with command `logs --tail`
2020-11-12T07:52:29.481583+00:00 heroku[run.2810]: State changed from starting to up
2020-11-12T07:52:33.681435+00:00 heroku[run.2810]: Process exited with status 127
2020-11-12T07:52:33.728441+00:00 heroku[run.2810]: State changed from up to complete
2020-11-12T07:54:17.364720+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=schedule-management-app.herokuapp.com request_id=5a9bb0b1-5095-44c8-acb1-0632cda59581 fwd="182.64.168.27" dyno= connect= service= status=503 bytes= protocol=https
2020-11-12T07:54:19.387732+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=schedule-management-app.herokuapp.com request_id=bebd1fa5-55d4-4da5-a0a4-998b4bec5807 fwd="182.64.168.27" dyno= connect= service= status=503 bytes= protocol=https
2020-11-12T07:54:56.265063+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=schedule-management-app.herokuapp.com request_id=5f8e7bf2-1de0-444b-85bd-e5bd1c2d0021 fwd="182.64.168.27" dyno= connect= service= status=503 bytes= protocol=https
2020-11-12T07:54:57.285648+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=schedule-management-app.herokuapp.com request_id=4a299aab-d7d2-4722-ae7e-e696b8d3f361 fwd="182.64.168.27" dyno= connect= service= status=503 bytes= protocol=https
2020-11-12T07:58:58.856040+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=schedule-management-app.herokuapp.com request_id=572807eb-60db-4cfd-9d94-d867c16ba55f fwd="34.227.83.108" dyno= connect= service= status=503 bytes= protocol=https
2020-11-12T07:58:58.887428+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=schedule-management-app.herokuapp.com request_id=d82b4c44-506d-4a29-94eb-f4ddb044ba58 fwd="34.227.83.108" dyno= connect= service= status=503 bytes= protocol=http
2020-11-12T07:59:04.492151+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=HEAD path="/" host=schedule-management-app.herokuapp.com request_id=7fe9e10d-a5bd-432f-bd70-c3d7aa0f4931 fwd="217.182.175.162" dyno= connect= service= status=503 bytes= protocol=https
2020-11-12T07:59:50.143201+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/robots.txt" host=schedule-management-app.herokuapp.com request_id=8f9dd1ec-d7b3-46be-aeee-d52dda0ae196 fwd="107.23.92.82" dyno= connect= service= status=503 bytes= protocol=https
2020-11-12T07:59:50.164349+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=schedule-management-app.herokuapp.com request_id=159cfbb3-c7ae-4c9c-8a1b-8e21783da8ea fwd="107.23.92.82" dyno= connect= service= status=503 bytes= protocol=https
2020-11-12T08:14:04.114629+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=schedule-management-app.herokuapp.com request_id=8ed69468-d73e-4331-8609-7c35a659ce78 fwd="182.64.168.27" dyno= connect= service= status=503 bytes= protocol=https
2020-11-12T08:14:04.947352+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=schedule-management-app.herokuapp.com request_id=57a5208a-06d3-4ed2-8e2c-657179f357ef fwd="182.64.168.27" dyno= connect= service= status=503 bytes= protocol=https

我的应用程序在我的系统上运行良好,所以我假设我在托管时犯了一个错误。请帮忙。

【问题讨论】:

    标签: reactjs heroku graphql web-deployment hasura


    【解决方案1】:

    您需要指定一个构建包。关注官方文档here。建议使用 Heroku CLI。使用这些说明将您的 repo 部署到 heroku 没有问题。

    如果您必须按照自己的方式进行操作(github 集成),您可以set the buildpack in app.json

    【讨论】:

    • 我尝试使用 CLI 部署我的应用程序,但是当我打开应用程序时,会显示一个空白屏幕。我不确定我做错了什么。这是我的配置的 Webpack 部分中显示的链接。 Heroke 中的变量:https://buildpack-registry.s3.amazonaws.com/buildpacks/mars/create-react-app.tgz
    • 那是正确的构建包。我在我的帐户中也看到了那个。我在部署时看到实际网页没有问题。
    • 在您的机器上尝试一个新文件夹。将 master 分支克隆到新目录中。然后,只需使用 CLI 说明和正确的 buildpack 以不同的应用程序名称推送到 Heroku。 (我在部署之前确实删除了 package-lock.json ,但我怀疑这是你的问题)。我不明白它如何只对我们一个人起作用......
    • 顺便说一句,你的手艺是here,直到我从我的heroku账户中删除这个应用程序
    • 我可以将 buildpack 添加到现有的 react 应用程序吗?我想我找到了问题所在。当我在 Hasura GraphQL 上设置我的数据库时,它会创建一个 heroku 应用程序。我已将代码推送到该应用程序,但可以设置 webpack
    猜你喜欢
    • 2018-02-15
    • 2021-11-18
    • 2020-01-19
    • 2018-12-04
    • 2018-07-01
    • 2021-10-17
    • 1970-01-01
    • 1970-01-01
    • 2017-06-17
    相关资源
    最近更新 更多