Deploying NodeJs App to Heroku

Samuel Tosin
2 min readApr 12, 2021

Firstly, sign up on heroku website but if you are an existing member you can login to your account.

Install heroku in your terminal. Open your command prompt/Git and install heroku globally to your terminal using :

$ npm install -g heroku 

The npm installation of heroku will only work if you have nodejs and npm installed in your command prompt/Git otherwise you can install heroku CLI manually using https://devcenter.heroku.com/articles/heroku-cli

You can create node js app on heroku using two different ways :

  1. go to your heroku dashboard after signing up, then click on create new app

2. Go to your Nodejs App local’ directory in your terminal, run :

$ heroku login

this is to authenticate your installation and after verifying your installation create your nodejs app on heroku with this :

$ heroku create

In your node js app local directory, check if your app is properly created on heroku using the command

$ git remote -v
heroku https://git.heroku.com/Node js app name (fetch)
heroku https://git.heroku.com/Node js app name (push)

if you have already created your heroku app in your dashboard just like we did in 1, you can easily add a remote to your local repository with the heroku git:remote command in other to deploy your app to heroku. All you need is your Heroku app’s name

$ heroku git:remote -a your-heroku-app-name
set git remote heroku to https://git.heroku.com/your-heroku-app-name.git

To deploy your Node js app to Heroku, you typically use the git push command to push the code from your local repository’s master or main branch to your heroku remote:

$ git push heroku master
Initializing repository, done.
updating 'refs/heads/master'
...

--

--

Samuel Tosin

Fullstack Developer, Javascript Developer (PERN, MERN).