Heroku Node.JS errors - node.js

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.

Related

Error: Cannot find module 'polka' on Heroku

I'm trying to deploy my sapper/svelte app to heroku but getting 'Error: Cannot find module 'polka'' this error. Interesting thing is that, it was perfectly fine and working. My package.json is correct and I am not checking my modules into git either. I tried disabling caching but it is no good. Anyone have any ideas?
2020-09-16T16:04:44.083385+00:00 app[web.1]: Error: Cannot find module 'polka'
2020-09-16T16:04:44.083386+00:00 app[web.1]: Require stack:
2020-09-16T16:04:44.083386+00:00 app[web.1]: - /app/__sapper__/build/server/server.js
2020-09-16T16:04:44.083386+00:00 app[web.1]: - /app/__sapper__/build/index.js
2020-09-16T16:04:44.083387+00:00 app[web.1]: at Function.Module._resolveFilename (internal/modules/cjs/loader.js:965:15)
2020-09-16T16:04:44.083392+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:841:27)
2020-09-16T16:04:44.083392+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:1025:19)
2020-09-16T16:04:44.083393+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:72:18)
2020-09-16T16:04:44.083393+00:00 app[web.1]: at Object.<anonymous> (/app/__sapper__/build/server/server.js:4:13)
2020-09-16T16:04:44.083394+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1137:30)
2020-09-16T16:04:44.083394+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
2020-09-16T16:04:44.083394+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:985:32)
2020-09-16T16:04:44.083395+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:878:14)
2020-09-16T16:04:44.083395+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:1025:19) {
2020-09-16T16:04:44.083396+00:00 app[web.1]: code: 'MODULE_NOT_FOUND',
2020-09-16T16:04:44.083396+00:00 app[web.1]: requireStack: [
2020-09-16T16:04:44.083397+00:00 app[web.1]: '/app/__sapper__/build/server/server.js',
2020-09-16T16:04:44.083397+00:00 app[web.1]: '/app/__sapper__/build/index.js'
2020-09-16T16:04:44.083397+00:00 app[web.1]: ]
2020-09-16T16:04:44.083398+00:00 app[web.1]: }
It turns out polka's version on my package.json was set to 'next'. So I changed it to it latest stable version and deleted package.lock.json file and ran 'npm install' to create a new lock file and then pushed it to heroku. Works perfectly fine.

Running `node index.js` from command line works but when I use the start script in my package.json I get an EADDRINUSE /usr/bin/local/node error

I can run node index.js from the directly from the command line but when I run the start script that has the same command I get an error.
Here is the relative server info:
const PORT = process.env.NODE || 3000
app.listen(PORT, () => console.log(`Server running on ${PORT}`))
Here is the package.json script:
"scripts": {
"start": "node index.js"
},
Here is the terminal output ran from the project root running it without the script:
> node index.js
Server running on port 3000
Here is the terminal output running it with the script:
>yarn start
yarn run v1.10.1
$ node index.js
events.js:183
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE /usr/local/bin/node
at Server.setupListenHandle [as _listen2] (net.js:1343:19)
at listenInCluster (net.js:1401:12)
at Server.listen (net.js:1496:5)
at Function.listen (/Users/mmelv/Workspace/Projects/Reportably/server/node_modules/express/lib/application.js:618:24)
at Object.<anonymous> (/Users/mmelv/Workspace/Projects/Reportably/server/index.js:29:5)
at Module._compile (module.js:653:30)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
at Function.Module.runMain (module.js:694:10)
at startup (bootstrap_node.js:204:16)
at bootstrap_node.js:625:3
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
This has boggled me for hours. I've tried sudo killall node, lsof -i tcp:3000 returns nothing. I've reinstalled and upgraded node.
Also, I get the same error when I try to deploy it to Heroku:
2018-10-07T15:47:56.000000+00:00 app[api]: Build succeeded
2018-10-07T15:47:58.569471+00:00 heroku[web.1]: Starting process with command `npm start`
2018-10-07T15:48:01.927982+00:00 app[web.1]:
2018-10-07T15:48:01.928007+00:00 app[web.1]: > server#1.0.0 start /app
2018-10-07T15:48:01.928009+00:00 app[web.1]: > node index.js
2018-10-07T15:48:01.928010+00:00 app[web.1]:
2018-10-07T15:48:02.936929+00:00 app[web.1]: events.js:183
2018-10-07T15:48:02.936974+00:00 app[web.1]: throw er; // Unhandled 'error' event
2018-10-07T15:48:02.936976+00:00 app[web.1]: ^
2018-10-07T15:48:02.936977+00:00 app[web.1]:
2018-10-07T15:48:02.936979+00:00 app[web.1]: Error: listen EADDRINUSE /app/.heroku/node/bin/node
2018-10-07T15:48:02.936981+00:00 app[web.1]: at Object._errnoException (util.js:992:11)
2018-10-07T15:48:02.936982+00:00 app[web.1]: at _exceptionWithHostPort (util.js:1014:20)
2018-10-07T15:48:02.936984+00:00 app[web.1]: at Server.setupListenHandle [as _listen2] (net.js:1338:19)
2018-10-07T15:48:02.936985+00:00 app[web.1]: at listenInCluster (net.js:1396:12)
2018-10-07T15:48:02.936987+00:00 app[web.1]: at Server.listen (net.js:1491:5)
2018-10-07T15:48:02.936989+00:00 app[web.1]: at Function.listen (/app/node_modules/express/lib/application.js:618:24)
2018-10-07T15:48:02.936990+00:00 app[web.1]: at Object.<anonymous> (/app/index.js:29:5)
2018-10-07T15:48:02.936992+00:00 app[web.1]: at Module._compile (module.js:652:30)
2018-10-07T15:48:02.936993+00:00 app[web.1]: at Object.Module._extensions..js (module.js:663:10)
2018-10-07T15:48:02.936995+00:00 app[web.1]: at Module.load (module.js:565:32)
2018-10-07T15:48:02.936996+00:00 app[web.1]: at tryModuleLoad (module.js:505:12)
2018-10-07T15:48:02.936998+00:00 app[web.1]: at Function.Module._load (module.js:497:3)
2018-10-07T15:48:02.936999+00:00 app[web.1]: at Function.Module.runMain (module.js:693:10)
2018-10-07T15:48:02.937001+00:00 app[web.1]: at startup (bootstrap_node.js:191:16)
2018-10-07T15:48:02.937003+00:00 app[web.1]: at bootstrap_node.js:612:3
2018-10-07T15:48:03.081497+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2018-10-07T15:48:03.082095+00:00 app[web.1]: npm ERR! errno 1
2018-10-07T15:48:03.083978+00:00 app[web.1]: npm ERR! server#1.0.0 start: `node index.js`
2018-10-07T15:48:03.088003+00:00 app[web.1]: npm ERR! Exit status 1
2018-10-07T15:48:03.088362+00:00 app[web.1]: npm ERR!
2018-10-07T15:48:03.088616+00:00 app[web.1]: npm ERR! Failed at the server#1.0.0 start script.
2018-10-07T15:48:03.088965+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
I'm not sure what else to do. Why can I run node index.js but not the start script that does the same thing?
I had to change process.env.NODE to process.env.PORT...
I know, I know...

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"

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

Error on deploy a NodeJS app in Heroku

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.

Resources