How to set up nodebootstrap at Heroku? - node.js

I'm using nodebootstrap to start a new nodejs project (http://nodebootstrap.io/) and it's running fine locally. But when I tried to deploy it to heroku, it showed me the follow errors:
2016-08-21T05:14:51.789857+00:00 heroku[web.1]: State changed from crashed to starting
2016-08-21T05:14:54.116827+00:00 heroku[web.1]: Starting process with command `node server.js`
2016-08-21T05:14:56.026808+00:00 app[web.1]: 21 Aug 05:14:56 - NOTICE [node_modules/nodebootstrap-server/app.js:57] Express server instance listening on port 31254
2016-08-21T05:14:56.104762+00:00 app[web.1]: module.js:341
2016-08-21T05:14:56.104766+00:00 app[web.1]: throw err;
2016-08-21T05:14:56.104769+00:00 app[web.1]: at Function.Module._resolveFilename (module.js:339:15)
2016-08-21T05:14:56.104773+00:00 app[web.1]: at Function.Module._load (module.js:290:25)
2016-08-21T05:14:56.104775+00:00 app[web.1]: at require (internal/module.js:20:19)
2016-08-21T05:14:56.104775+00:00 app[web.1]: at Object.<anonymous> (/app/lib/api/index.js:2:9)
2016-08-21T05:14:56.104776+00:00 app[web.1]: at Module._compile (module.js:413:34)
2016-08-21T05:14:56.104777+00:00 app[web.1]: at Module.load (module.js:357:32)
2016-08-21T05:14:56.104777+00:00 app[web.1]: at Function.Module._load (module.js:314:12)
2016-08-21T05:14:56.158230+00:00 heroku[web.1]: State changed from starting to crashed
2016-08-21T05:14:56.148890+00:00 heroku[web.1]: Process exited with status 1
Anybody has any idea how to fix this?

Problem solved - I have some unresolved dependency issue that I didn't found when running locally in dev mode

Related

Node deployment to heroku fails

I am trying to deploy a basic app to heroku and i am getting an error. I have included heroku log.
2018-08-12T11:19:35.082630+00:00 app[web.1]: Error: Cannot find module '/app/server/server.js'
2018-08-12T11:19:35.082632+00:00 app[web.1]: at Function.Module._resolveFilename (module.js:536:15)
2018-08-12T11:19:35.082634+00:00 app[web.1]: at Function.Module._load (module.js:466:25)
2018-08-12T11:19:35.082635+00:00 app[web.1]: at Function.Module.runMain (module.js:676:10)
2018-08-12T11:19:35.082651+00:00 app[web.1]: at startup (bootstrap_node.js:187:16)
2018-08-12T11:19:35.082653+00:00 app[web.1]: at bootstrap_node.js:608:3
2018-08-12T11:19:35.165790+00:00 heroku[web.1]: State changed from starting to crashed
2018-08-12T11:19:35.168329+00:00 heroku[web.1]: State changed from crashed to starting
2018-08-12T11:19:38.372891+00:00 heroku[web.1]: Starting process with command `node server/server.js`
2018-08-12T11:19:40.669347+00:00 heroku[web.1]: Process exited with status 1
2018-08-12T11:19:40.685006+00:00 heroku[web.1]: State changed from starting to crashed
2018-08-12T11:19:40.573913+00:00 app[web.1]: module.js:538
2018-08-12T11:19:40.573936+00:00 app[web.1]: throw err;
2018-08-12T11:19:40.573938+00:00 app[web.1]: ^
2018-08-12T11:19:40.573940+00:00 app[web.1]:
2018-08-12T11:19:40.573942+00:00 app[web.1]: Error: Cannot find module '/app/server/server.js'
2018-08-12T11:19:40.573943+00:00 app[web.1]: at Function.Module._resolveFilename (module.js:536:15)
2018-08-12T11:19:40.573945+00:00 app[web.1]: at Function.Module._load (module.js:466:25)
2018-08-12T11:19:40.573947+00:00 app[web.1]: at Function.Module.runMain (module.js:676:10)
2018-08-12T11:19:40.573949+00:00 app[web.1]: at startup (bootstrap_node.js:187:16)
2018-08-12T11:19:40.573951+00:00 app[web.1]: at bootstrap_node.js:608:3
I have included the start script like this
"scripts": {
"start": "node server/server.js",
"test": "export NODE_ENV=test || SET \"NODE_ENV=test\" && mocha \"./{,!(node_modules)/**/}*.test.js\""
},
please tell me what i am missing. I have also attached my root directory folders image.image
As soon as you are already using Procfile, you can specify there:
web: node server/server.js
By default, Heroku looks into the Profice first in order to start server. And only then it looks into package.json's start script.

Heroku node.js keeps crashing because of node_modules?

This is the heroku logs
2017-12-13T16:08:29.000000+00:00 app[api]: Build succeeded
2017-12-13T16:08:46.328161+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2017-12-13T16:08:46.498068+00:00 heroku[web.1]: Process exited with status 143
2017-12-13T16:08:53.490378+00:00 app[web.1]: module.js:538
2017-12-13T16:08:53.490391+00:00 app[web.1]: throw err;
2017-12-13T16:08:53.490391+00:00 app[web.1]: ^
2017-12-13T16:08:53.490392+00:00 app[web.1]:
2017-12-13T16:08:53.490392+00:00 app[web.1]: Error: Cannot find module './decimal128'
2017-12-13T16:08:53.490393+00:00 app[web.1]: at Function.Module._resolveFilename (module.js:536:15)
2017-12-13T16:08:53.490394+00:00 app[web.1]: at Function.Module._load (module.js:466:25)
2017-12-13T16:08:53.490394+00:00 app[web.1]: at Module.require (module.js:579:17)
2017-12-13T16:08:53.490395+00:00 app[web.1]: at require (internal/module.js:11:18)
2017-12-13T16:08:53.490395+00:00 app[web.1]: at Object.<anonymous> (/app/node_modules/mongoose/lib/drivers/node-mongodb-native/index.js:6:22)
2017-12-13T16:08:53.490396+00:00 app[web.1]: at Module._compile (module.js:635:30)
2017-12-13T16:08:53.490396+00:00 app[web.1]: at Object.Module._extensions..js (module.js:646:10)
2017-12-13T16:08:53.490397+00:00 app[web.1]: at Module.load (module.js:554:32)
2017-12-13T16:08:53.490397+00:00 app[web.1]: at tryModuleLoad (module.js:497:12)
2017-12-13T16:08:53.490398+00:00 app[web.1]: at Function.Module._load (module.js:489:3)
2017-12-13T16:08:53.582814+00:00 heroku[web.1]: State changed from starting to crashed
2017-12-13T16:08:53.555998+00:00 heroku[web.1]: Process exited with status 1
2017-12-13T16:08:51.503070+00:00 heroku[web.1]: Starting process with command `node app.js`
2017-12-13T16:10:20.313936+00:00 heroku[web.1]: State changed from crashed to starting
2017-12-13T16:10:23.590155+00:00 heroku[web.1]: Starting process with command `node app.js`
2017-12-13T16:10:26.548414+00:00 heroku[web.1]: Process exited with status 1
2017-12-13T16:10:26.463026+00:00 app[web.1]: module.js:538
2017-12-13T16:10:26.463042+00:00 app[web.1]: throw err;
2017-12-13T16:10:26.463042+00:00 app[web.1]: ^
2017-12-13T16:10:26.463043+00:00 app[web.1]:
2017-12-13T16:10:26.463044+00:00 app[web.1]: Error: Cannot find module './decimal128'
2017-12-13T16:10:26.463045+00:00 app[web.1]: at Function.Module._resolveFilename (module.js:536:15)
2017-12-13T16:10:26.463045+00:00 app[web.1]: at Function.Module._load (module.js:466:25)
2017-12-13T16:10:26.463046+00:00 app[web.1]: at Module.require (module.js:579:17)
2017-12-13T16:10:26.463046+00:00 app[web.1]: at require (internal/module.js:11:18)
2017-12-13T16:10:26.463047+00:00 app[web.1]: at Object.<anonymous> (/app/node_modules/mongoose/lib/drivers/node-mongodb-native/index.js:6:22)
2017-12-13T16:10:26.463048+00:00 app[web.1]: at Module._compile (module.js:635:30)
2017-12-13T16:10:26.463048+00:00 app[web.1]: at Object.Module._extensions..js (module.js:646:10)
2017-12-13T16:10:26.463049+00:00 app[web.1]: at Module.load (module.js:554:32)
2017-12-13T16:10:26.463050+00:00 app[web.1]: at tryModuleLoad (module.js:497:12)
2017-12-13T16:10:26.463050+00:00 app[web.1]: at Function.Module._load (module.js:489:3)
2017-12-13T16:10:26.576992+00:00 heroku[web.1]: State changed from starting to crashed
Via trial and error and using the heroku rollback it seems that the problem isn't in my app.js file but in the node_modules. However I can't seem to find a fix. I've tried reinstalling the node_modules.
It works locally but not when I deploy it on Heroku.
also suddenly I have a package-lock.json file. perhaps thats is a clue?
It's complaining about the decimal128 module, I would double check the relative path to the module from the file that is requiring it. Looks like right now it's looking for it in the same folder as the file "/decimal128".
I fixed it myself by going through everything updating everything and downgrading mongodb to "mongodb": "2.2.33"

Error with mongodb driver on Heroku: Cannot find module 'mongodb-core'

I'm trying to upgrade my Node.js Express app to a newer driver for Mongodb. My package.json has "mongodb": "^2.0.40". It runs fine on my machine, and I'm able to deploy to Heroku fine (as in, no warning/errors). However, the app crashes upon use, with this error:
2015-09-14T13:03:52.225525+00:00 heroku[web.1]: Starting process with command `node app.js`
2015-09-14T13:03:52.271972+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2015-09-14T13:03:54.315461+00:00 heroku[web.1]: Process exited with status 143
2015-09-14T13:03:54.701499+00:00 app[web.1]: module.js:338
2015-09-14T13:03:54.701522+00:00 app[web.1]: throw err;
2015-09-14T13:03:54.701523+00:00 app[web.1]: ^
2015-09-14T13:03:54.701525+00:00 app[web.1]: Error: Cannot find module 'mongodb-core'
2015-09-14T13:03:54.701526+00:00 app[web.1]: at Function.Module._resolveFilename (module.js:336:15)
2015-09-14T13:03:54.701527+00:00 app[web.1]: at Function.Module._load (module.js:278:25)
2015-09-14T13:03:54.701529+00:00 app[web.1]: at require (module.js:384:17)
2015-09-14T13:03:54.701528+00:00 app[web.1]: at Module.require (module.js:365:17)
2015-09-14T13:03:54.701531+00:00 app[web.1]: at Object.<anonymous> (/app/node_modules/mongodb/index.js:2:12)
2015-09-14T13:03:54.701532+00:00 app[web.1]: at Module._compile (module.js:460:26)
2015-09-14T13:03:54.701533+00:00 app[web.1]: at Object.Module._extensions..js (module.js:478:10)
2015-09-14T13:03:54.701534+00:00 app[web.1]: at Module.load (module.js:355:32)
2015-09-14T13:03:54.701535+00:00 app[web.1]: at Function.Module._load (module.js:310:12)
2015-09-14T13:03:54.701536+00:00 app[web.1]: at Module.require (module.js:365:17)
2015-09-14T13:03:55.561071+00:00 heroku[web.1]: State changed from starting to crashed
2015-09-14T13:03:55.548974+00:00 heroku[web.1]: Process exited with status 1
I've tried various versions of mongodb driver, to no avail.
if you use mongodb-core, you should specify it in package.json like here:
"dependencies": {
"express": "~4.9.x"
, "pg": "~4.4.x"
, "mongodb": "2.0.14"
, "mongodb-core": "~1.0"
},
after pushing it to git, check the log:
remote: -----> Build succeeded!
remote: ├── express#4.9.8
remote: ├── mongodb#2.0.14
remote: ├── mongodb-core#1.0.5
remote: └── pg#4.4.1

Heroku Node JS app error - says it can't find my main module

I have a small node.js app running at heroku. Everything was fine until today.
I made a tiny change in one of my .jade files and re-deployed. Now I am getting this in my heroku logs:
2013-01-09T20:44:40+00:00 heroku[slugc]: Slug compilation started
2013-01-09T20:44:53+00:00 heroku[api]: Release v36 created by steve#donie.us
2013-01-09T20:44:53+00:00 heroku[api]: Deploy c299759 by steve#donie.us
`013-01-09T20:44:55+00:00 heroku[web.1]: Starting process with command `node ./doniewebapp.js
2013-01-09T20:44:56+00:00 app[web.1]: at Function.Module._resolveFilename (module.js:338:15)
2013-01-09T20:44:56+00:00 app[web.1]: throw err;
2013-01-09T20:44:56+00:00 app[web.1]: at Function.Module._load (module.js:280:25)
'013-01-09T20:44:56+00:00 app[web.1]: Error: Cannot find module '/app/doniewebapp.js
2013-01-09T20:44:56+00:00 app[web.1]: at process.startup.processNextTick.process._tickCallback (node.js:244:9)
2013-01-09T20:44:56+00:00 app[web.1]:
2013-01-09T20:44:56+00:00 app[web.1]: module.js:340
2013-01-09T20:44:56+00:00 app[web.1]: ^
2013-01-09T20:44:56+00:00 app[web.1]: at Module.runMain (module.js:492:10)
2013-01-09T20:44:57+00:00 heroku[web.1]: Process exited with status 1
2013-01-09T20:44:54+00:00 heroku[slugc]: Slug compilation finished
2013-01-09T20:44:53+00:00 heroku[web.1]: State changed from crashed to starting
2013-01-09T20:44:57+00:00 heroku[web.1]: State changed from starting to crashed
I have confirmed that the doniewebapp.js file is still there, and I can even run the app if I use
heroku run node doniewebapp.js
Any ideas greatly appreciated.
I had the same trouble.
Starting process with command `node ./doniewebapp.js <-- Backquote does not exist.
$ vi Procfile
:set fileformat=unix
:w
I have solved the problem.

Heroku Node.JS errors

Heroku gives me this error, after I deploy the node.js app of mine. Do you have any idea what is error message means? Thank you!
2013-01-14T22:50:34+00:00 heroku[web.1]: State changed from crashed to starting
2013-01-14T22:50:36+00:00 heroku[web.1]: Starting process with command `node app.js`
2013-01-14T22:50:37+00:00 app[web.1]:
2013-01-14T22:50:37+00:00 app[web.1]: /app/node_modules/express/lib/router/index.js:252
2013-01-14T22:50:37+00:00 app[web.1]: throw new Error(msg);
2013-01-14T22:50:37+00:00 app[web.1]: ^
2013-01-14T22:50:37+00:00 app[web.1]: Error: .get() requires callback functions but got a [object Undefined]
2013-01-14T22:50:37+00:00 app[web.1]: at Router.route.Route.sensitive (/app/node_modules/express/lib/router/index.js:252:11)
2013-01-14T22:50:37+00:00 app[web.1]: at Array.forEach (native)
2013-01-14T22:50:37+00:00 app[web.1]: at Router.route (/app/node_modules/express/lib/router/index.js:248:13)
2013-01-14T22:50:37+00:00 app[web.1]: at Router.methods.forEach.Router.(anonymous function) [as get] (/app/node_modules/express/lib/router/index.js:270:16)
2013-01-14T22:50:37+00:00 app[web.1]: at Function.methods.forEach.app.(anonymous function) [as get] (/app/node_modules/express/lib/application.js:411:26)
2013-01-14T22:50:37+00:00 app[web.1]: at Routes.self.init (/app/routes.js:23:9)
2013-01-14T22:50:37+00:00 app[web.1]: at Object.<anonymous> (/app/app.js:42:8)
2013-01-14T22:50:37+00:00 app[web.1]: at Module._compile (module.js:449:26)
2013-01-14T22:50:37+00:00 app[web.1]: at Object.Module._extensions..js (module.js:467:10)
2013-01-14T22:50:37+00:00 app[web.1]: at Module.load (module.js:356:32)
2013-01-14T22:50:38+00:00 heroku[web.1]: State changed from starting to crashed
2013-01-14T22:50:38+00:00 heroku[web.1]: Process exited with status 1
Try checking your /app/routes.js file, there will be a route that doesn't have two parameters. Try commenting out around lines 23.
Or isn't being defined properly, but this issue shouldn't be related to Heroku, and it should throw an error when you boot node app.js locally shrug
Hope you managed to sort it!
Seems that's your app's problem and not a issue related to Heroku.
You should try to running the project locally, and figure out the problems.
Check your `app/routes.js' file.

Resources