The solution is to simply rename app.js to anything else except server.js (ie main.js) and reference that in bin/www by pointing to it in the /bin/www file: var app = require('../app'); to var app = require('../main');
The package.json file will get called by ELB when it launches the application server. Here it has the instruction to run the start script node bin/www
This is the bin/www file that gets run. We see the require to ../main and the app.set('port'...)
Then the main.js file that runs the routing and all:
When I created the project, the main.js file was named app.js. The problem this caused was based on the priority ELB start sequences. ELB will launch the application and check first to see if app.js exists -- if it does exist, it runs node app.js, otherwise it will check if package.json exists and try to run npm start.
When the main.js had the name app.js ELB tried to start the whole application by running it. However this file doesn't open any ports.
where is that /bin/www file? on the ex2 instance?
figured out the express 4 structure. literally did express inside a blank 'test' folder and updated my /bin/www following the rename. still no dice :/
I update the answer to show the directory structure. I struggled with it a while. You are using ELB (Elastic Beanstalk) right? The directory I show is the whole thing that you upload to ELB. Are you uploading via github or a zip file? For zip you may want to try two things: zip the whole folder recibel in my cas, OR zip the contents within recibel.
ooh thanks for the update. super clear. i did figure it out! so yay. but hopefully the next confused soul has an easier time.