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

时间:2020-05-14 03:36:26

标签: javascript node.js reactjs heroku create-react-app

在尝试在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

任何帮助将不胜感激!

2 个答案:

答案 0 :(得分:0)

您的procfile文本文件不正确。参见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应用程序在线:

enter image description here

答案 1 :(得分:0)

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

相关问题