Python and Node.js on Heroku

Maybe the lack of doc is intentional, but to have Flask/React app on Heroku, you need:
– to run grunt build in a sub-folder (project/static/Gruntfile.js), add a package.json at the root folder. Based on the knowledge that heroku will run ‘npm install’

  "dependencies": {
    "grunt": "^0.4.5",
    "grunt-cli": "*"
  "scripts": {
    "postinstall": "npm install -g grunt-cli bower browserify && cd project/static && npm install && cd ../.. && grunt heroku --gruntfile project/static/Gruntfile.js"

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