Node.js project deployment with Heroku and Github

After picking up the basics, setting up the Node.js environment and sample app on a mac is dead simple. This book literally holds your hand through the entire process. Super easy. The tricky part for me was that I wanted to share this sample app with a couple of friends (who are also new to this whole web app building thing!).

I had heard about Heroku in the past and seemed like they abstract a lot of the server side stuff, and they support Node.js. Fair enough, getting started with Heroku was straight forward too. Think of them as an alternative to AWS – in fact, in some ways, way simpler than AWS (not that I have used AWS extensively, but I have tried to and it looked a lot more complicated than Heroku for a beginner). This is where to go for step by step directions.

Warning – you will have to know a little bit about Git before working with Heroku as well to truly have an appreciation for what you are doing. They use Git to deploy your local app to their servers!

Finally, the tricky part. Getting your local code synced to Github (only if you really want to use Github – I do as a way to learn, but you can happily skip this if you want). Once you have your sample app setup locally, and you have pushed it to Heroku based on the steps in the link above, there are four steps:

  1. Got to Github.com, get an account and learn the basics of git.
  2. Setup Github on your local machine.
  3. Create a Github repo.
  4. Go to your Heroku account and link your Github repo in the settings.
  5. Now, on your sample app directory in your local machine terminal, simply push to both Github and Heroku. See this (if you followed the steps above, replace “origin” with “github” in your push command from this link).
  6. If for any reason, you have some contents in your Github repo at the time of creation, make sure you do a pull and merge before pushing new code from your local machine.

Now, every new commit you make from your local machine will be visible on both your Github and Heroku repos. Have fun!