Home > Mobile >  Success deploy on Heroku but I get Application Error using Express Node.JS
Success deploy on Heroku but I get Application Error using Express Node.JS

Time:01-07

This is my first time trying to deploy, and I choose Heroku, please pardon me, and I'm deploying it as a fun project for practice purposes.

I've followed this site instruction to Folder Structure

Update 1:

After fixing the Procfile with web: node ./src/index.js, the error that requires the index.js is fixed, but it lead me to another problem that I really don't know how to fix with.

Here's the log of it:

2022-01-06T19:22:51.002284 00:00 app[web.1]: internal/modules/cjs/loader.js:905
2022-01-06T19:22:51.002303 00:00 app[web.1]:   throw err;
2022-01-06T19:22:51.002304 00:00 app[web.1]:   ^
2022-01-06T19:22:51.002304 00:00 app[web.1]: 
2022-01-06T19:22:51.002304 00:00 app[web.1]: Error: Cannot find module '@supabase/supabase-js'
2022-01-06T19:22:51.002304 00:00 app[web.1]: Require stack:
2022-01-06T19:22:51.002305 00:00 app[web.1]: - /app/src/index.js
2022-01-06T19:22:51.002305 00:00 app[web.1]:     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
2022-01-06T19:22:51.002306 00:00 app[web.1]:     at Function.Module._load (internal/modules/cjs/loader.js:746:27)
2022-01-06T19:22:51.002306 00:00 app[web.1]:     at Module.require (internal/modules/cjs/loader.js:974:19)
2022-01-06T19:22:51.002306 00:00 app[web.1]:     at require (internal/modules/cjs/helpers.js:93:18)
2022-01-06T19:22:51.002306 00:00 app[web.1]:     at Object.<anonymous> (/app/src/index.js:9:26)
2022-01-06T19:22:51.002307 00:00 app[web.1]:     at Module._compile (internal/modules/cjs/loader.js:1085:14)
2022-01-06T19:22:51.002307 00:00 app[web.1]:     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
2022-01-06T19:22:51.002308 00:00 app[web.1]:     at Module.load (internal/modules/cjs/loader.js:950:32)
2022-01-06T19:22:51.002308 00:00 app[web.1]:     at Function.Module._load (internal/modules/cjs/loader.js:790:12)
2022-01-06T19:22:51.002308 00:00 app[web.1]:     at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12) {
2022-01-06T19:22:51.002309 00:00 app[web.1]:   code: 'MODULE_NOT_FOUND',
2022-01-06T19:22:51.002309 00:00 app[web.1]:   requireStack: [ '/app/src/index.js' ]
2022-01-06T19:22:51.002309 00:00 app[web.1]: }
2022-01-06T19:22:51.275795 00:00 heroku[web.1]: State changed from starting to crashed
2022-01-06T19:22:48.000000 00:00 app[api]: Build succeeded

CodePudding user response:

Heroku can't find your index.js file:

Error: Cannot find module '/app/index.js'

It looks like your index.js is inside a directory called src/. That should be reflected in your Procfile:

web: node src/index.js
  •  Tags:  
  • Related