Node.js on AWS Beanstalk

Are you trying to deploy a Express/Node.js application to AWS Beanstalk? I tried today and these are the things you should take into account if you are using the AWS Console.

  1. When uploading a .zip you need to zip the content of your project folder. Not the folder.
  2. Name your main file “app.js” or “server.js” or create the “npm start”.
  3. You can define a own node command to run your app in the configuration of your Beanstalk application.
  4. If using Nginx the port will be 8081 according to this stackoverflow.com question. To don’t hardcode the port use const port = process.env.PORT || 3000.

This might be it…

Oh, and socket.io is throwing an error. This is a problem for another day. Also, I should take a look at the command line tool for deploying Beanstalk. It seems I can define a aws region for an app.