Search code examples
node.jsreactjsherokudeploymentmern

Application error - I'm getting an error message after deployment to Heroku even though my app works fine in development


I tried to publish my app to Heroku but I got the below error message:

An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details. You can do this from the Heroku CLI with the command

heroku logs --tail

I checked the logs and got the below info which I cannot decipher:

(node:40446) SyntaxError Plugin: heroku: /home/me/.local/share/heroku/config.json: Unexpected end of JSON input
module: @oclif/[email protected]
task: runHook prerun
plugin: heroku
root: /snap/heroku/4076
See more details with DEBUG=*
2021-09-20T22:05:15.905073+00:00 app[api]: Deploy 17474356 by user [email protected]
2021-09-20T22:05:15.922889+00:00 app[api]: Scaled to web@1:Free by user [email protected]
2021-09-20T22:05:17.000000+00:00 app[api]: Build succeeded
2021-09-20T22:05:22.406972+00:00 heroku[web.1]: Starting process with command `npm start`
2021-09-20T22:05:23.782304+00:00 app[web.1]: 
2021-09-20T22:05:23.782323+00:00 app[web.1]: > [email protected] start /app
2021-09-20T22:05:23.782323+00:00 app[web.1]: > node server.js
2021-09-20T22:05:23.782323+00:00 app[web.1]: 
2021-09-20T22:05:24.264339+00:00 app[web.1]: /app/server.js:4
2021-09-20T22:05:24.264356+00:00 app[web.1]: const path = requier("path");
2021-09-20T22:05:24.264357+00:00 app[web.1]: ^
2021-09-20T22:05:24.264357+00:00 app[web.1]: 
2021-09-20T22:05:24.264358+00:00 app[web.1]: ReferenceError: requier is not defined
2021-09-20T22:05:24.264358+00:00 app[web.1]: at Object.<anonymous> (/app/server.js:4:14)
2021-09-20T22:05:24.264359+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1072:14)
2021-09-20T22:05:24.264359+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
2021-09-20T22:05:24.264360+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:937:32)
2021-09-20T22:05:24.264360+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:778:12)
2021-09-20T22:05:24.264360+00:00 app[web.1]: at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
2021-09-20T22:05:24.264361+00:00 app[web.1]: at internal/main/run_main_module.js:17:47
2021-09-20T22:05:24.276266+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2021-09-20T22:05:24.276629+00:00 app[web.1]: npm ERR! errno 1
2021-09-20T22:05:24.285403+00:00 app[web.1]: npm ERR! [email protected] start: `node server.js`
2021-09-20T22:05:24.285546+00:00 app[web.1]: npm ERR! Exit status 1
2021-09-20T22:05:24.285701+00:00 app[web.1]: npm ERR!
2021-09-20T22:05:24.285813+00:00 app[web.1]: npm ERR! Failed at the [email protected] start script.
2021-09-20T22:05:24.285905+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2021-09-20T22:05:24.304319+00:00 app[web.1]: 
2021-09-20T22:05:24.307416+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2021-09-20T22:05:24.307459+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2021-09-20T22_05_24_286Z-debug.log
2021-09-20T22:05:24.477472+00:00 heroku[web.1]: Process exited with status 1
2021-09-20T22:05:24.608841+00:00 heroku[web.1]: State changed from starting to crashed
2021-09-20T22:05:24.616776+00:00 heroku[web.1]: State changed from crashed to starting
2021-09-20T22:05:30.615650+00:00 heroku[web.1]: Starting process with command `npm start`
2021-09-20T22:05:32.154416+00:00 app[web.1]: 
2021-09-20T22:05:32.154432+00:00 app[web.1]: > [email protected] start /app
2021-09-20T22:05:32.154432+00:00 app[web.1]: > node server.js
2021-09-20T22:05:32.154433+00:00 app[web.1]: 
2021-09-20T22:05:32.491951+00:00 app[web.1]: /app/server.js:4
2021-09-20T22:05:32.491970+00:00 app[web.1]: const path = requier("path");
2021-09-20T22:05:32.491970+00:00 app[web.1]: ^
2021-09-20T22:05:32.491970+00:00 app[web.1]: 
2021-09-20T22:05:32.491971+00:00 app[web.1]: ReferenceError: requier is not defined
2021-09-20T22:05:32.491971+00:00 app[web.1]: at Object.<anonymous> (/app/server.js:4:14)
2021-09-20T22:05:32.491971+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1072:14)
2021-09-20T22:05:32.491972+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
2021-09-20T22:05:32.491972+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:937:32)
2021-09-20T22:05:32.491972+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:778:12)
2021-09-20T22:05:32.491975+00:00 app[web.1]: at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
2021-09-20T22:05:32.491975+00:00 app[web.1]: at internal/main/run_main_module.js:17:47
2021-09-20T22:05:32.502469+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2021-09-20T22:05:32.504151+00:00 app[web.1]: npm ERR! errno 1
2021-09-20T22:05:32.507359+00:00 app[web.1]: npm ERR! [email protected] start: `node server.js`
2021-09-20T22:05:32.507361+00:00 app[web.1]: npm ERR! Exit status 1
2021-09-20T22:05:32.507362+00:00 app[web.1]: npm ERR!
2021-09-20T22:05:32.507362+00:00 app[web.1]: npm ERR! Failed at the [email protected] start script.
2021-09-20T22:05:32.507363+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2021-09-20T22:05:32.517624+00:00 app[web.1]: 
2021-09-20T22:05:32.517629+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2021-09-20T22:05:32.517630+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2021-09-20T22_05_32_508Z-debug.log
2021-09-20T22:05:32.654009+00:00 heroku[web.1]: Process exited with status 1
2021-09-20T22:05:32.790052+00:00 heroku[web.1]: State changed from starting to crashed
2021-09-20T22:10:11.627061+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=pure-thicket-06601.herokuapp.com request_id=0c6e85f7-f539-406d-a7fa-9d92a88ea7de fwd="89.211.153.133" dyno= connect= service= status=503 bytes= protocol=https
2021-09-20T22:10:12.524329+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=pure-thicket-06601.herokuapp.com request_id=c9282c5e-54aa-4735-802d-fd782041837a fwd="89.211.153.133" dyno= connect= service= status=503 bytes= protocol=https
2021-09-20T22:13:28.000000+00:00 app[api]: Build started by user [email protected]
2021-09-20T22:15:44.820687+00:00 app[api]: Deploy d8ef6129 by user [email protected]
2021-09-20T22:15:44.820687+00:00 app[api]: Release v4 created by user [email protected]
2021-09-20T22:15:45.198887+00:00 heroku[web.1]: State changed from crashed to starting
2021-09-20T22:15:46.000000+00:00 app[api]: Build succeeded
2021-09-20T22:15:51.404944+00:00 heroku[web.1]: Starting process with command `npm start`
2021-09-20T22:15:52.687305+00:00 app[web.1]: 
2021-09-20T22:15:52.687323+00:00 app[web.1]: > [email protected] start /app
2021-09-20T22:15:52.687323+00:00 app[web.1]: > node server.js
2021-09-20T22:15:52.687324+00:00 app[web.1]: 
2021-09-20T22:15:53.120246+00:00 app[web.1]: /app/server.js:4
2021-09-20T22:15:53.120260+00:00 app[web.1]: const path = requier("path");
2021-09-20T22:15:53.120260+00:00 app[web.1]: ^
2021-09-20T22:15:53.120261+00:00 app[web.1]: 
2021-09-20T22:15:53.120262+00:00 app[web.1]: ReferenceError: requier is not defined
2021-09-20T22:15:53.120262+00:00 app[web.1]: at Object.<anonymous> (/app/server.js:4:14)
2021-09-20T22:15:53.120263+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1072:14)
2021-09-20T22:15:53.120263+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
2021-09-20T22:15:53.120264+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:937:32)
2021-09-20T22:15:53.120264+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:778:12)
2021-09-20T22:15:53.120265+00:00 app[web.1]: at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
2021-09-20T22:15:53.120265+00:00 app[web.1]: at internal/main/run_main_module.js:17:47
2021-09-20T22:15:53.132041+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2021-09-20T22:15:53.132277+00:00 app[web.1]: npm ERR! errno 1
2021-09-20T22:15:53.143479+00:00 app[web.1]: npm ERR! [email protected] start: `node server.js`
2021-09-20T22:15:53.143539+00:00 app[web.1]: npm ERR! Exit status 1
2021-09-20T22:15:53.143612+00:00 app[web.1]: npm ERR!
2021-09-20T22:15:53.143669+00:00 app[web.1]: npm ERR! Failed at the [email protected] start script.
2021-09-20T22:15:53.143714+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2021-09-20T22:15:53.156377+00:00 app[web.1]: 
2021-09-20T22:15:53.156477+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2021-09-20T22:15:53.156529+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2021-09-20T22_15_53_144Z-debug.log
2021-09-20T22:15:53.320983+00:00 heroku[web.1]: Process exited with status 1
2021-09-20T22:15:53.393003+00:00 heroku[web.1]: State changed from starting to crashed
2021-09-20T22:16:11.040791+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=pure-thicket-06601.herokuapp.com request_id=fcca437f-5d66-44db-a8dc-8bb638db78ac fwd="89.211.153.133" dyno= connect= service= status=503 bytes= protocol=https
2021-09-20T22:16:11.928866+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=pure-thicket-06601.herokuapp.com request_id=d12c938a-0a91-4947-8d10-6af6f31a7b9f fwd="89.211.153.133" dyno= connect= service= status=503 bytes= protocol=https
2021-09-20T22:17:36.704916+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=pure-thicket-06601.herokuapp.com request_id=5ed37742-5272-486e-b762-323e16c53cf1 fwd="89.211.153.133" dyno= connect= service= status=503 bytes= protocol=https

Any idea what went wrong? Everything worked perfectly fine in localhost but now even locally I'm having problems after deployment.


Solution

  • There is a spelling error. Replace

    const path = requier("path");
    

    with

    const path = require("path");
    

    and deploy it again to see if it works.