尝试部署React App时出现Heroku错误代码H10

时间:2020-04-25 12:24:59

标签: reactjs heroku

我有点喜欢Web开发。我建立了一个React网站,但无法将其部署在heroku上。

package.json:

"scripts": {
    "dev": "react-scripts start",
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject",
    "heroku-postbuild": "npm run build"
    },

我的package.json旁边有一个Procfile:

web:npm start

控制台在我执行herolu日志--tail时抛出此错误:

2020-04-25T09:16:16.142345+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=vertikalreunion.herokuapp.com request_id=f7d41b53-de86-4b4d-83fb-994cab236581 fwd="82.64.226.67" dyno= connect= service= status=503 bytes= protocol=https
2020-04-25T09:16:27.595683+00:00 heroku[web.1]: State changed from crashed to starting
2020-04-25T09:16:51.753401+00:00 app[web.1]: 
2020-04-25T09:16:51.753423+00:00 app[web.1]: > vertikal@0.1.0 start /app
2020-04-25T09:16:51.753423+00:00 app[web.1]: > react-scripts start
2020-04-25T09:16:51.753423+00:00 app[web.1]: 
2020-04-25T09:16:54.009357+00:00 heroku[web.1]: State changed from starting to crashed
2020-04-25T09:16:53.900786+00:00 app[web.1]: ℹ 「wds」: Project is running at http://172.16.53.194/
2020-04-25T09:16:53.901127+00:00 app[web.1]: ℹ 「wds」: webpack output is served from
2020-04-25T09:16:53.901196+00:00 app[web.1]: ℹ 「wds」: Content not from webpack is served from /app/public
2020-04-25T09:16:53.901262+00:00 app[web.1]: ℹ 「wds」: 404s will fallback to /
2020-04-25T09:16:53.901440+00:00 app[web.1]: Starting the development server...
2020-04-25T09:16:53.901458+00:00 app[web.1]: 
2020-04-25T09:16:55.709712+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=vertikalreunion.herokuapp.com request_id=09ca158b-97f3-4693-9393-cd06adf078f5 fwd="82.64.226.67" dyno= connect= service= status=503 bytes= protocol=https
2020-04-25T09:19:08.785514+00:00 heroku[web.1]: State changed from crashed to starting
2020-04-25T09:19:30.469551+00:00 app[web.1]: 
2020-04-25T09:19:30.469601+00:00 app[web.1]: > vertikal@0.1.0 start /app
2020-04-25T09:19:30.469602+00:00 app[web.1]: > react-scripts start
2020-04-25T09:19:30.469602+00:00 app[web.1]: 
2020-04-25T09:19:32.893506+00:00 heroku[web.1]: State changed from starting to crashed
2020-04-25T09:19:32.802075+00:00 app[web.1]: ℹ 「wds」: Project is running at http://172.19.5.2/
2020-04-25T09:19:32.802231+00:00 app[web.1]: ℹ 「wds」: webpack output is served from
2020-04-25T09:19:32.802333+00:00 app[web.1]: ℹ 「wds」: Content not from webpack is served from /app/public
2020-04-25T09:19:32.802403+00:00 app[web.1]: ℹ 「wds」: 404s will fallback to /
2020-04-25T09:19:32.802595+00:00 app[web.1]: Starting the development server...
2020-04-25T09:19:32.802596+00:00 app[web.1]: 
2020-04-25T09:41:17.364623+00:00 heroku[web.1]: State changed from crashed to starting
2020-04-25T09:41:38.385042+00:00 app[web.1]: 
2020-04-25T09:41:38.385060+00:00 app[web.1]: > vertikal@0.1.0 start /app
2020-04-25T09:41:38.385061+00:00 app[web.1]: > react-scripts start
2020-04-25T09:41:38.385061+00:00 app[web.1]: 
2020-04-25T09:41:40.279176+00:00 heroku[web.1]: State changed from starting to crashed
2020-04-25T09:41:40.184921+00:00 app[web.1]: ℹ 「wds」: Project is running at http://172.17.183.158/
2020-04-25T09:41:40.185258+00:00 app[web.1]: ℹ 「wds」: webpack output is served from
2020-04-25T09:41:40.185335+00:00 app[web.1]: ℹ 「wds」: Content not from webpack is served from /app/public
2020-04-25T09:41:40.185406+00:00 app[web.1]: ℹ 「wds」: 404s will fallback to /
2020-04-25T09:41:40.185581+00:00 app[web.1]: Starting the development server...
2020-04-25T09:41:40.185582+00:00 app[web.1]: 
2020-04-25T10:23:03.438472+00:00 heroku[web.1]: State changed from crashed to starting
2020-04-25T10:23:25.751986+00:00 app[web.1]: 
2020-04-25T10:23:25.752002+00:00 app[web.1]: > vertikal@0.1.0 start /app
2020-04-25T10:23:25.752002+00:00 app[web.1]: > react-scripts start
2020-04-25T10:23:25.752002+00:00 app[web.1]: 
2020-04-25T10:23:28.152557+00:00 heroku[web.1]: State changed from starting to crashed
2020-04-25T10:23:28.051089+00:00 app[web.1]: ℹ 「wds」: Project is running at http://172.18.19.226/
2020-04-25T10:23:28.051680+00:00 app[web.1]: ℹ 「wds」: webpack output is served from
2020-04-25T10:23:28.051715+00:00 app[web.1]: ℹ 「wds」: Content not from webpack is served from /app/public
2020-04-25T10:23:28.051831+00:00 app[web.1]: ℹ 「wds」: 404s will fallback to /
2020-04-25T10:23:28.052068+00:00 app[web.1]: Starting the development server...
2020-04-25T10:23:28.052068+00:00 app[web.1]: 
2020-04-25T11:42:46.689638+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=vertikalreunion.herokuapp.com request_id=5ca84f44-a006-4deb-a61b-b288a3a04109 fwd="82.64.226.67" dyno= connect= service= status=503 bytes= protocol=https
2020-04-25T11:43:34.646592+00:00 app[api]: Starting process with command `printenv` by user velluetp@gmail.com
2020-04-25T11:43:52.591042+00:00 heroku[run.1701]: State changed from starting to up
2020-04-25T11:43:57.024009+00:00 heroku[run.1701]: State changed from up to complete
2020-04-25T11:46:45.991288+00:00 heroku[web.1]: State changed from crashed to starting
2020-04-25T11:47:07.851528+00:00 app[web.1]: 
2020-04-25T11:47:07.851557+00:00 app[web.1]: > vertikal@0.1.0 start /app
2020-04-25T11:47:07.851558+00:00 app[web.1]: > react-scripts start
2020-04-25T11:47:07.851558+00:00 app[web.1]: 
2020-04-25T11:47:10.275055+00:00 heroku[web.1]: State changed from starting to crashed
2020-04-25T11:47:10.153858+00:00 app[web.1]: ℹ 「wds」: Project is running at http://172.16.160.154/
2020-04-25T11:47:10.154471+00:00 app[web.1]: ℹ 「wds」: webpack output is served from
2020-04-25T11:47:10.154540+00:00 app[web.1]: ℹ 「wds」: Content not from webpack is served from /app/public
2020-04-25T11:47:10.154659+00:00 app[web.1]: ℹ 「wds」: 404s will fallback to /
2020-04-25T11:47:10.154945+00:00 app[web.1]: Starting the development server...
2020-04-25T11:47:10.154946+00:00 app[web.1]: 
2020-04-25T12:01:11.000000+00:00 app[api]: Build started by user velluetp@gmail.com
2020-04-25T12:01:57.000000+00:00 app[api]: Build failed -- check your build output: https://dashboard.heroku.com/apps/9c187c58-5551-4ceb-8b9b-bc3ef1e25101/activity/builds/69305220-a27f-436d-8841-9f17a17017e4
2020-04-25T12:11:22.000000+00:00 app[api]: Build started by user velluetp@gmail.com
2020-04-25T12:13:26.032267+00:00 app[api]: Deploy d028d641 by user velluetp@gmail.com
2020-04-25T12:13:26.032267+00:00 app[api]: Release v12 created by user velluetp@gmail.com
2020-04-25T12:13:27.646789+00:00 heroku[web.1]: State changed from crashed to starting
2020-04-25T12:13:39.000000+00:00 app[api]: Build succeeded
2020-04-25T12:13:48.056119+00:00 app[web.1]: 
2020-04-25T12:13:48.056133+00:00 app[web.1]: > vertikal@0.1.0 start /app
2020-04-25T12:13:48.056133+00:00 app[web.1]: > react-scripts start
2020-04-25T12:13:48.056134+00:00 app[web.1]: 
2020-04-25T12:13:50.150679+00:00 heroku[web.1]: State changed from starting to crashed
2020-04-25T12:13:50.228845+00:00 heroku[web.1]: State changed from crashed to starting
2020-04-25T12:13:50.028096+00:00 app[web.1]: ℹ 「wds」: Project is running at http://172.18.46.74/
2020-04-25T12:13:50.028436+00:00 app[web.1]: ℹ 「wds」: webpack output is served from
2020-04-25T12:13:50.028512+00:00 app[web.1]: ℹ 「wds」: Content not from webpack is served from /app/public
2020-04-25T12:13:50.028579+00:00 app[web.1]: ℹ 「wds」: 404s will fallback to /
2020-04-25T12:13:50.028756+00:00 app[web.1]: Starting the development server...
2020-04-25T12:13:50.028757+00:00 app[web.1]: 
2020-04-25T12:14:16.995981+00:00 app[web.1]: 
2020-04-25T12:14:16.995997+00:00 app[web.1]: > vertikal@0.1.0 start /app
2020-04-25T12:14:16.995997+00:00 app[web.1]: > react-scripts start
2020-04-25T12:14:16.995998+00:00 app[web.1]: 
2020-04-25T12:14:19.993371+00:00 heroku[web.1]: State changed from starting to crashed
2020-04-25T12:14:19.866235+00:00 app[web.1]: ℹ 「wds」: Project is running at http://172.17.253.118/
2020-04-25T12:14:19.866644+00:00 app[web.1]: ℹ 「wds」: webpack output is served from
2020-04-25T12:14:19.866749+00:00 app[web.1]: ℹ 「wds」: Content not from webpack is served from /app/public
2020-04-25T12:14:19.866883+00:00 app[web.1]: ℹ 「wds」: 404s will fallback to /
2020-04-25T12:14:19.867083+00:00 app[web.1]: Starting the development server...
2020-04-25T12:14:19.867084+00:00 app[web.1]: 
2020-04-25T12:14:22.011941+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=vertikalreunion.herokuapp.com request_id=e69732b6-851b-46ca-9853-4a014a45f282 fwd="82.64.226.67" dyno= connect= service= status=503 bytes= protocol=https
2020-04-25T12:14:33.524773+00:00 app[api]: Starting process with command `rails console` by user velluetp@gmail.com
2020-04-25T12:14:54.113480+00:00 heroku[run.9122]: State changed from starting to up
2020-04-25T12:14:58.860885+00:00 heroku[run.9122]: State changed from up to complete

即使努力尝试在互联网上找到解决方案,我也不知道问题的根源。

1 个答案:

答案 0 :(得分:0)

不要用于启动脚本,请删除“ dev”:“ react-scripts start”,

使用create-react-app并部署到

  1. 不要删除favicon.ico和manifest.json

  2. 也在package.json以上脚本中插入“ engines”:{ “ npm”:“ 6.x”, “ node”:“ 12.x” }

//注意通过键入npm -v和node -v来检查节点和NPM版本以获取准确的版本//

  1. 在heroku创建命令之后的heroku中,转到heroku并将设置下的构建方式更改为https://github.com/mars/create-react-app-buildpack

不要添加其他脚本或更改开始,构建脚本!

这应该清除在部署到heroku时的所有h10错误,如果我不建议您创建一个新目录并在该目录中复制文件并重新开始,则此链接是部署的绝佳指南

https://dev.to/smithmanny/deploy-your-react-app-to-heroku-2b6f