javascriptnode.jsreactjsherokucreate-react-app

Application Error Deploying create-react-app on Heroku


I have tried numerous online solutions or fixes for this error while trying to deploy a very basic React.js app on Heroku. My app builds successfully when I run git push heroku master , but every time I try to open it I am getting an application error with logs reading:

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

To my understanding, everything should be set up correctly. My repo can be found here https://github.com/christulin/ravenousReactApp.

Any help would be very much appreciated!


Solution

  • You have incorrect procfile text file. See Define a Procfile. Change the content from web: node app.js to web: node server.js.

    Besides, the imported modules of your code have path issue, it will cause build failures. This is PR

    Before logs:

    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
    

    after logs:

    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
    

    Your web application is online:

    enter image description here