Application error for Heroku node.js

I was trying to push my node.js app to Heroku. When I run node app

locally, it works fine. And when I run git push heroku

to deploy, there were no errors on the command line either. But when I do heroku open

, the Application Error page appears. And then I did heroku run bash

to go straight to the server and run on it node app

, and again no error. However, an application error appears on the web page.

When I checked the logs through heroku logs --tail

, here are the errors:

2014-09-07T05:43:16.819546+00:00 heroku[web.1]: State changed from crashed to starting
2014-09-07T05:43:18.617745+00:00 heroku[web.1]: Starting process with command `node app.js`
2014-09-07T05:43:19.219404+00:00 app[web.1]: module.js:340
2014-09-07T05:43:19.219809+00:00 app[web.1]:     throw err;
2014-09-07T05:43:19.219814+00:00 app[web.1]:           ^
2014-09-07T05:43:19.219075+00:00 app[web.1]: 
2014-09-07T05:43:19.222538+00:00 app[web.1]: Error: Cannot find module 'express'
2014-09-07T05:43:19.222541+00:00 app[web.1]:     at Function.Module._resolveFilename (module.js:338:15)
2014-09-07T05:43:19.222543+00:00 app[web.1]:     at Module.require (module.js:364:17)
2014-09-07T05:43:19.222547+00:00 app[web.1]:     at Module._compile (module.js:456:26)
2014-09-07T05:43:19.222542+00:00 app[web.1]:     at Function.Module._load (module.js:280:25)
2014-09-07T05:43:19.222550+00:00 app[web.1]:     at Module.load (module.js:356:32)
2014-09-07T05:43:19.222545+00:00 app[web.1]:     at require (module.js:380:17)
2014-09-07T05:43:19.222546+00:00 app[web.1]:     at Object.<anonymous> (/app/app.js:1:77)
2014-09-07T05:43:19.222549+00:00 app[web.1]:     at Object.Module._extensions..js (module.js:474:10)
2014-09-07T05:43:19.222553+00:00 app[web.1]:     at Function.Module.runMain (module.js:497:10)
2014-09-07T05:43:19.222551+00:00 app[web.1]:     at Function.Module._load (module.js:312:12)
2014-09-07T05:43:19.944481+00:00 heroku[web.1]: Process exited with status 8
2014-09-07T05:43:19.958025+00:00 heroku[web.1]: State changed from starting to crashed
2014-09-07T06:31:23.233643+00:00 heroku[web.1]: State changed from cra
shed to starting
2014-09-07T06:31:25.484465+00:00 heroku[web.1]: Starting process with command `node app.js`
2014-09-07T06:31:26.746959+00:00 app[web.1]: 
2014-09-07T06:31:26.747625+00:00 app[web.1]:     throw err;
2014-09-07T06:31:26.754734+00:00 app[web.1]: Error: Cannot find module 'express'
2014-09-07T06:31:26.747455+00:00 app[web.1]: module.js:340
2014-09-07T06:31:26.754750+00:00 app[web.1]:     at Module.load (module.js:356:32)
2014-09-07T06:31:26.754754+00:00 app[web.1]:     at Function.Module.runMain (module.js:497:10)
2014-09-07T06:31:26.747630+00:00 app[web.1]:           ^
2014-09-07T06:31:26.754752+00:00 app[web.1]:     at Function.Module._load (module.js:312:12)
2014-09-07T06:31:26.754749+00:00 app[web.1]:     at Object.Module._extensions..js (module.js:474:10)
2014-09-07T06:31:26.754742+00:00 app[web.1]:     at Module.require (module.js:364:17)
2014-09-07T06:31:26.754740+00:00 app[web.1]:     at Function.Module._load (module.js:280:25)
2014-09-07T06:31:26.754744+00:00 app[web.1]:     at require (module.js:380:17)
2014-09-07T06:31:26.754746+00:00 app[web.1]:     at Object.<anonymous> (/app/app.js:1:77)
2014-09-07T06:31:26.754747+00:00 app[web.1]:     at Module._compile (module.js:456:26)
2014-09-07T06:31:26.754739+00:00 app[web.1]:     at Function.Module._resolveFilename (module.js:338:15)
2014-09-07T06:31:27.640851+00:00 heroku[web.1]: Process exited with status 8
2014-09-07T06:31:27.648865+00:00 heroku[web.1]: State changed from starting to crashed
2014-09-07T06:57:24.387733+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=redefining-web-design.herokuapp.com request_id=b20732af-40f4-4705-bd85-16a605b4c8ed fwd="116.15.50.88   ,220.255.2.31" dyno= connect= service= status=503 bytes=
2014-09-07T07:11:52.954250+00:00 heroku[api]: Starting process with command `bash` by anthony.send@gmail.com
2014-09-07T07:11:54.845805+00:00 heroku[run.7802]: Awaiting client
2014-09-07T07:11:55.877349+00:00 heroku[run.7802]: Starting process with command `bash`
2014-09-07T07:11:55.214871+00:00 heroku[run.7802]: State changed from starting to up
2014-09-07T07:16:32.135955+00:00 heroku[run.7802]: Process exited with status 130
2014-09-07T07:16:32.147198+00:00 heroku[run.7802]: State changed from up to complete
2014-09-07T07:16:43+00:00 heroku[slug-compiler]: Slug compilation started
2014-09-07T07:16:46.543796+00:00 heroku[api]: Deploy b88168d by anthony.send@gmail.com
2014-09-07T07:16:46.543796+00:00 heroku[api]: Release v5 created by anthony.send@gmail.com
2014-09-07T07:16:46+00:00 heroku[slug-compiler]: Slug compilation finished
2014-09-07T07:16:46.727022+00:00 heroku[web.1]: State changed from crashed to starting
2014-09-07T07:16:48.970345+00:00 heroku[web.1]: Starting process with command `node app.js`
2014-09-07T07:16:49.649144+00:00 app[web.1]: module.js:340
2014-09-07T07:16:49.649150+00:00 app[web.1]:     throw err;
2014-09-07T07:16:49.649154+00:00 app[web.1]:           ^
2014-09-07T07:16:49.652236+00:00 app[web.1]:     at require (module.js:380:17)
2014-09-07T07:16:49.652226+00:00 app[web.1]: Error: Cannot find module 'express'
2014-09-07T07:16:49.652240+00:00 app[web.1]:     at Object.Module._extensions..js (module.js:474:10)
2014-09-07T07:16:49.652231+00:00 app[web.1]:     at Function.Module._resolveFilename (module.js:338:15)
2014-09-07T07:16:49.652239+00:00 app[web.1]:     at Module._compile (module.js:456:26)
2014-09-07T07:16:49.652232+00:00 app[web.1]:     at Function.Module._load (module.js:280:25)
2014-09-07T07:16:49.652234+00:00 app[web.1]:     at Module.require (module.js:364:17)
2014-09-07T07:16:49.652242+00:00 app[web.1]:     at Module.load (module.js:356:32)
2014-09-07T07:16:49.652245+00:00 app[web.1]:     at Function.Module.runMain (module.js:497:10)
2014-09-07T07:16:49.652243+00:00 app[web.1]:     at Function.Module._load (module.js:312:12)
2014-09-07T07:16:49.652238+00:00 app[web.1]:     at Object.<anonymous> (/app/app.js:1:77)
2014-09-07T07:16:49.648613+00:00 app[web.1]: 
2014-09-07T07:16:50.430646+00:00 heroku[web.1]: State changed from starting to crashed
2014-09-07T07:16:50.431568+00:00 heroku[web.1]: State c
hanged from crashed to starting
2014-09-07T07:16:50.412485+00:00 heroku[web.1]: Process exited with status 8
2014-09-07T07:16:51.795738+00:00 heroku[web.1]: Starting process with command `node app.js`
2014-09-07T07:16:52.326711+00:00 app[web.1]: module.js:340
2014-09-07T07:16:52.327018+00:00 app[web.1]:           ^
2014-09-07T07:16:52.330126+00:00 app[web.1]: Error: Cannot find module 'express'
2014-09-07T07:16:52.330131+00:00 app[web.1]:     at Function.Module._resolveFilename (module.js:338:15)
2014-09-07T07:16:52.326262+00:00 app[web.1]: 
2014-09-07T07:16:52.327010+00:00 app[web.1]:     throw err;
2014-09-07T07:16:52.330134+00:00 app[web.1]:     at Module.require (module.js:364:17)
2014-09-07T07:16:52.330141+00:00 app[web.1]:     at Object.Module._extensions..js (module.js:474:10)
2014-09-07T07:16:52.330143+00:00 app[web.1]:     at Module.load (module.js:356:32)
2014-09-07T07:16:52.330144+00:00 app[web.1]:     at Function.Module._load (module.js:312:12)
2014-09-07T07:16:52.330146+00:00 app[web.1]:     at Function.Module.runMain (module.js:497:10)
2014-09-07T07:16:52.330137+00:00 app[web.1]:     at require (module.js:380:17)
2014-09-07T07:16:52.330133+00:00 app[web.1]:     at Function.Module._load (module.js:280:25)
2014-09-07T07:16:52.330138+00:00 app[web.1]:     at Object.<anonymous> (/app/app.js:1:77)
2014-09-07T07:16:52.330140+00:00 app[web.1]:     at Module._compile (module.js:456:26)
2014-09-07T07:16:53.006419+00:00 
heroku[web.1]: State changed from starting to crashed
2014-09-07T07:16:53.355392+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=redefining-web-design.herokuapp.com request_id=3126eef5-0ab0-4932-b3cf-dbb97e21d5ef fwd="54.234.54.24" dyno= connect= service= status=503 bytes=
2014-09-07T07:16:54.988896+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=redefining-web-design.herokuapp.com request_id=bc0dfc6b-3983-4bde-afec-62c872883713 fwd="116.15.50.88   ,220.255.2.215" dyno= connect= service= status=503 bytes=
2014-09-07T07:18:34.403133+00:00 heroku[api]: Starting process with command `bash` by anthony.send@gmail.com
2014-09-07T07:18:36.327048+00:00 heroku[run.5491]: Awaiting client
2014-09-07T07:18:36.823328+00:00 heroku[run.5491]: Starting process with command `bash`
2014-09-07T07:18:36.622179+00:00 heroku[run.5491]: State changed from starting to up
2014-09-07T07:19:06.382664+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=redefining-web-design.herokuapp.com request_id=14b3e7e1-3ecc-4666-9f97-4ca70d6f5924 fwd="116.15.50.88   ,220.255.2.66" dyno= connect= service= status=503 bytes=
2014-09-07T07:19:52.190628+00:00 heroku[api]: Starting process with command `bash` by anthony.send@gmail.com
2014-09-07T07:19:53.926014+00:00 heroku[run.1948]: Awaiting client
2014-09-07T07:19:54.940182+00:00 heroku[run.1948]: Starting process with command `bash`
2014-09-07T07:19:54.247484+00:00 heroku[run.1948]: State changed from starting to up
2014-09-07T07:20:04.500159+00:00 heroku[run.1948]: State changed from up to complete
2014-09-07T07:20:04.492947+00:00 heroku[run.1948]: Process exited with status 130
2014-09-07T07:21:23.644016+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=redefining-web-design.herokuapp.com request_id=9db4918d-1f68-4329-a3cc-6a8a3f9817e5 fwd="116.15.50.88   ,220.255.2.188" dyno= connect= service= status=503 bytes=
2014-09-07T07:25:06.104220+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=redefining-web-design.herokuapp.com request_id=c39ecaf6-34af-4a5e-a728-0c6bfe223ce6 fwd="116.15.50.88   ,220.255.2.36" dyno= connect= service= status=503 bytes=

      

So it looks like what is happening is that Heroku cannot find Express. While I'm pretty sure I didn't push the entire node_module folder and I specified node_modules in my .gitignore, I'm pretty sure this might not be the problem. I'm sure I read in the docs that Heroku will install the required modules when I click on it my application. Also, I heroku run bash

ran again and double checked, and of course there is a node_modules folder which contains express and ejs-locals.

Now I seriously have no idea what's going on. It would really be appreciated if someone can enlighten me on this - thanks a lot in advance.

+3


source to share





All Articles