Need help with deploy on heroku


#1

server.js app code
http.listen(process.env.PORT || 3000, function(){
console.log(‘listening on’, http.address().port);
});

errors with heroku logs

2017-07-28T22:14:46.409299+00:00 heroku[web.1]: State changed from crashed to starting
2017-07-28T22:14:48.300480+00:00 heroku[web.1]: Starting process with command npm start
2017-07-28T22:14:50.160387+00:00 app[web.1]:
2017-07-28T22:14:50.160410+00:00 app[web.1]: > chat-example@0.0.0 start /app
2017-07-28T22:14:50.160411+00:00 app[web.1]: > node server.js
2017-07-28T22:14:50.160412+00:00 app[web.1]:
2017-07-28T22:14:50.511206+00:00 app[web.1]: info: socket.io started
2017-07-28T22:14:50.588977+00:00 app[web.1]: /app/server.js:208
2017-07-28T22:14:50.588980+00:00 app[web.1]: http.listen(process.env.PORT || 3000, function(){
2017-07-28T22:14:50.588981+00:00 app[web.1]: ^
2017-07-28T22:14:50.588982+00:00 app[web.1]:
2017-07-28T22:14:50.588985+00:00 app[web.1]: TypeError: http.listen is not a function
2017-07-28T22:14:50.588986+00:00 app[web.1]: at Object. (/app/server.js:208:6)
2017-07-28T22:14:50.588986+00:00 app[web.1]: at Module._compile (module.js:570:32)
2017-07-28T22:14:50.588987+00:00 app[web.1]: at Object.Module._extensions…js (module.js:579:10)
2017-07-28T22:14:50.588987+00:00 app[web.1]: at Module.load (module.js:487:32)
2017-07-28T22:14:50.588990+00:00 app[web.1]: at tryModuleLoad (module.js:446:12)
2017-07-28T22:14:50.588990+00:00 app[web.1]: at Function.Module._load (module.js:438:3)
2017-07-28T22:14:50.588991+00:00 app[web.1]: at Module.runMain (module.js:604:10)
2017-07-28T22:14:50.588991+00:00 app[web.1]: at run (bootstrap_node.js:389:7)
2017-07-28T22:14:50.588992+00:00 app[web.1]: at startup (bootstrap_node.js:149:9)
2017-07-28T22:14:50.588993+00:00 app[web.1]: at bootstrap_node.js:504:3
2017-07-28T22:14:50.603362+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2017-07-28T22:14:50.603530+00:00 app[web.1]: npm ERR! errno 1
2017-07-28T22:14:50.603642+00:00 app[web.1]: npm ERR! chat-example@0.0.0 start: node server.js
2017-07-28T22:14:50.603723+00:00 app[web.1]: npm ERR! Exit status 1
2017-07-28T22:14:50.603822+00:00 app[web.1]: npm ERR!
2017-07-28T22:14:50.603905+00:00 app[web.1]: npm ERR! Failed at the chat-example@0.0.0 start script.
2017-07-28T22:14:50.603992+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2017-07-28T22:14:50.604761+00:00 app[web.1]:
2017-07-28T22:14:50.604902+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2017-07-28T22:14:50.604964+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2017-07-28T22_14_50_600Z-debug.log
2017-07-28T22:14:50.688883+00:00 heroku[web.1]: State changed from starting to crashed
2017-07-28T22:14:50.677883+00:00 heroku[web.1]: Process exited with status 1
jmswift:~/workspace (master) $

theres really a lot I appreciate any help I can get though, I was running this app in the c9 server and it worked perfectly


#2

I’m not 100% if this will help or not or if you’ve fixed it already. However, heroku doesn’t allow you to set ports. It assigns you an random port each time that it loads your deployment. You can get the current port with an environment variable, and use that if you need it in your code.