在 Heroku 上部署 create-react-app 应用程序错误

Application Error Deploying create-react-app on Heroku

我在尝试在 Heroku 上部署一个非常基本的 React.js 应用程序时尝试了许多在线解决方案或修复此错误。当我 运行 git push heroku master 时,我的应用程序构建成功,但每次我尝试打开它时,我都会收到一个应用程序错误,日志如下:

2020-05-14T03:16:02.986304+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=ravenous-react-application.herokuapp.com request_id=b4546431-d236-4c53-90de-cea6185c1d86 fwd="34.100.75.75" dyno= connect= service= status=503 bytes= protocol=https

据我了解,一切都应该正确设置。我的回购可以在这里找到 https://github.com/christulin/ravenousReactApp.

非常感谢任何帮助!

您的回答不正确procfile text file. See Define a Procfile。将内容从 web: node app.js 更改为 web: node server.js

另外,你的代码导入的模块有路径问题,会导致构建失败。这是PR

记录之前:

2020-05-19T04:48:13.097431+00:00 heroku[web.1]: State changed from starting to crashed
2020-05-19T04:48:13.015546+00:00 app[web.1]: internal/modules/cjs/loader.js:979
2020-05-19T04:48:13.015557+00:00 app[web.1]: throw err;
2020-05-19T04:48:13.015558+00:00 app[web.1]: ^
2020-05-19T04:48:13.015561+00:00 app[web.1]: 
2020-05-19T04:48:13.015561+00:00 app[web.1]: Error: Cannot find module '/app/app.js'
2020-05-19T04:48:13.015562+00:00 app[web.1]: at Function.Module._resolveFilename (internal/modules/cjs/loader.js:976:15)
2020-05-19T04:48:13.015563+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:859:27)
2020-05-19T04:48:13.015563+00:00 app[web.1]: at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
2020-05-19T04:48:13.015563+00:00 app[web.1]: at internal/main/run_main_module.js:17:47 {
2020-05-19T04:48:13.015564+00:00 app[web.1]: code: 'MODULE_NOT_FOUND',
2020-05-19T04:48:13.015564+00:00 app[web.1]: requireStack: []
2020-05-19T04:48:13.015564+00:00 app[web.1]: }
2020-05-19T04:48:16.833580+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=tranquil-chamber-64150.herokuapp.com request_id=b7e02a7c-c7bc-4a96-9d01-197be203938e fwd="118.183.246.243" dyno= connect= service= status=503 bytes= protocol=https
2020-05-19T04:48:20.721578+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=tranquil-chamber-64150.herokuapp.com request_id=38422262-6c70-4850-af93-7caf9f3d80cb fwd="118.183.246.243" dyno= connect= service= status=503 bytes= protocol=https
2020-05-19T04:48:36.257873+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=tranquil-chamber-64150.herokuapp.com request_id=d2f7a9e2-01ee-4bf1-953d-2a2074c39ed6 fwd="118.183.246.243" dyno= connect= service= status=503 bytes= protocol=https

记录后:

2020-05-19T04:56:54.432489+00:00 heroku[web.1]: State changed from crashed to starting
2020-05-19T04:57:00.000000+00:00 app[api]: Build succeeded
2020-05-19T04:57:08.755488+00:00 heroku[web.1]: State changed from starting to up
2020-05-19T04:57:09.895681+00:00 heroku[router]: at=info method=GET path="/" host=tranquil-chamber-64150.herokuapp.com request_id=db435d3a-961c-40e5-b9a1-c51cc2059606 fwd="118.183.246.243" dyno=web.1 connect=0ms service=23ms status=200 bytes=2722 protocol=https
2020-05-19T04:57:10.539700+00:00 heroku[router]: at=info method=GET path="/reset.css" host=tranquil-chamber-64150.herokuapp.com request_id=d5f3f55b-2605-4e8b-9bfd-b195bb45cc22 fwd="118.183.246.243" dyno=web.1 connect=0ms service=5ms status=200 bytes=1292 protocol=https
2020-05-19T04:57:10.542937+00:00 heroku[router]: at=info method=GET path="/static/css/main.ba71d789.chunk.css" host=tranquil-chamber-64150.herokuapp.com request_id=b00408f2-cf8a-4cda-acb6-1535683c4cf6 fwd="118.183.246.243" dyno=web.1 connect=1ms service=5ms status=200 bytes=3787 protocol=https
2020-05-19T04:57:10.817450+00:00 heroku[router]: at=info method=GET path="/static/js/2.15bfb385.chunk.js" host=tranquil-chamber-64150.herokuapp.com request_id=28eb63be-e3f2-4006-afce-f114d45539b6 fwd="118.183.246.243" dyno=web.1 connect=2ms service=12ms status=200 bytes=131654 protocol=https
2020-05-19T04:57:11.043548+00:00 heroku[router]: at=info method=GET path="/static/js/main.9d3c77a1.chunk.js" host=tranquil-chamber-64150.herokuapp.com request_id=09329487-90ac-4529-9473-7c990f4aef87 fwd="118.183.246.243" dyno=web.1 connect=3ms service=5ms status=200 bytes=5526 protocol=https
2020-05-19T04:57:25.207521+00:00 heroku[router]: at=info method=GET path="/static/media/background_search_desktop.902df4c5.jpg" host=tranquil-chamber-64150.herokuapp.com request_id=bf1a2880-e00d-420f-b7bd-b0a94e522572 fwd="118.183.246.243" dyno=web.1 connect=1ms service=103ms status=200 bytes=3133600 protocol=https

您的 Web 应用程序已在线:

我通过安装 buildbpack https://github.com/mars/create-react-app-buildpack 并添加带有此 web: bin/boot 的 procfile 来解决我的问题,希望对您有所帮助。