How to deploy node app to heroku

I found Heroku’s document on how to deploy node.js app insufficient. I wrote down my steps of deployment for future references.

Step1, add Procfile to the project

//Note, filename has to be exactly "Procfile"

web: node app.js

Step2, install heroku toolbelt on local machine.

Step3, create a heroku account on their website.

Step4, login in the console

heroku login

heroku create

Step5, change app name. Because Heorku generated a random app name for you, you might want to change it to something more meaningful. In my case, I changed it to prelinked.

Step6, update the git remote of the local repo since the app name has been changed.

//add heroku as a git remote

git remote add heroku

Step7, add SSH key to heroku account. Go to Account page, and copy and paste your local machine’s SSH key into the settings.

Step8, push git to remote master

git push local_branch_name heroku:master

Step9, setup environment variables. This is important yet often over looked. You want to run the following command in terminal, such that “env_var_one” will be available in Node.js’s process.env.env_var_one

heroku config:add env_var_one='YOUR API SECRET KEY'

Step10, turn on the dyno.

heroku ps:scale web=1