Error on deploy a NodeJS app in Heroku - node.js

I'm getting the error:
2012-01-28T00:13:51+00:00 heroku[web.1]: Starting process with command `node server.js`
2012-01-28T00:13:51+00:00 app[web.1]:
2012-01-28T00:13:51+00:00 app[web.1]: node.js:134
2012-01-28T00:13:51+00:00 app[web.1]: throw e; // process.nextTick error, or 'error' event on first tick
2012-01-28T00:13:51+00:00 app[web.1]: ^
2012-01-28T00:13:51+00:00 app[web.1]: at Array.<anonymous> (module.js:423:10)
2012-01-28T00:13:51+00:00 app[web.1]: Error: Cannot find module '/app/server.js'
2012-01-28T00:13:51+00:00 app[web.1]: at Function._resolveFilename (module.js:320:11)
2012-01-28T00:13:51+00:00 app[web.1]: at Function._load (module.js:266:25)
2012-01-28T00:13:51+00:00 app[web.1]: at EventEmitter._tickCallback (node.js:126:26)
My Node app server is in server.js at the root, I have no idea how to fix this.
I've done it from cloud9ide and it works fine, I did a deploy from there to heroku.

It looks like something is trying to require('server') somewhere in your app, which isn't necessary. The error is coming from module.js which deals with require-ing node modules. If you could provide your Procfile and maybe some source code it might be easier to pin down the problem, but based on first glance it looks like there's a relative path pointing to /app/server.js somewhere in your server code which shouldn't be doing so.

Related

hidden error while deploying website to heroku

A few days ago I added a schema file to my website folder so I could use MongoDB with the website. On the surface everything has worked fine but when I deployed the website to Heroku I get the next lines of error on the logs:
2022-06-04T07:14:38.698455+00:00 app[web.1]: node:internal/modules/cjs/loader:936
2022-06-04T07:14:38.698560+00:00 app[web.1]: throw err;
2022-06-04T07:14:38.698560+00:00 app[web.1]: ^
2022-06-04T07:14:38.698560+00:00 app[web.1]: Error: Cannot find module './../models/anime
2022-06-04T07:14:38.698561+00:00 app[web.1]: Require stack:
2022-06-04T07:14:38.698561+00:00 app[web.1]: - /app/routes/watch.js
2022-06-04T07:14:38.698561+00:00 app[web.1]: - /app/app.js
2022-06-04T07:14:38.698563+00:00 app[web.1]: at Function.Module._resolveFilename
2022-06-04T07:14:38.698577+00:00 app[web.1]: code: 'MODULE_NOT_FOUND',
2022-06-04T07:14:38.698577+00:00 app[web.1]: requireStack: [ '/app/routes/watch.js', '/app/app.js']

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.

How to set up nodebootstrap at Heroku?

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

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