Deploy Node.js application to Heroku

in Node.js / No Comments

In the earlier post, created the node.js sample application. Now we will learn how to deploy node.js application to Heroku.
Installation process I have checked in Ubuntu system.

Deploy Node.js application to Heroku by Anil Kumar Panigrahi

Deploy Node.js application to Heroku by Anil Kumar Panigrahi

Prerequisites of Heroku

To deploy to Heroku, we need to push our application code to remote repository.

Step 1: We need download and install Heroku toolbelt by below command.

wget -O- https://toolbelt.heroku.com/install-ubuntu.sh | sh

Step 2: To verify that your installation is successful, run the following command in your terminal

heroku --version

Output:

heroku-toolbelt/3.43.9 (x86_64-linux-gnu) ruby/2.3.1
heroku-cli/5.2.39-010a227 (linux-amd64) go1.6.2

Step 3: Once toolbelt is running, then log in and use it

heroku login
Email :
Password:

Deploying to Heroku

Create New App in Heroku, App name and select the region. In few seconds your app will ready.

Create application in Heroku screen1 -- Deploy Node.js application to Heroku

Create application in heroku screen1 — Deploy Node.js application to Heroku

Create application in Heroku screen2 -- Deploy Node.js application to Heroku

Create application in Heroku screen2 — Deploy Node.js application to Heroku

Go to settings page and get the Git URL.

Application in Heroku -- Deploy Node.js application to Heroku

Application in Heroku — Deploy Node.js application to Heroku

Run the below commands in your terminal

Step 1:

mkdir [APP Folder]
cd [APP Folder]

[APP Folder] – specify your application name

Step 2: Initialise the Git

git init

Step 3: Add the remote Git repository application

heroku git:remote -a anillabs

Step 4: Check the versions

node -v
npm -v
git --version

Step 5: Create Procfile file with below content

web: node app.js

Step 6: To add files to Git

git add .

Step 7: To commit with message to Git

git commit -am "anillabs first commit"

Step 8: To push files to Heroku

git push heroku master
Deployment  screen-1 -- Deploy Node.js application to Heroku

Deployment screen-1 — Deploy Node.js application to Heroku

Deployment  screen-2 -- Deploy Node.js application to Heroku

Deployment screen-2 — Deploy Node.js application to Heroku

Deployment  screen-3 -- Deploy Node.js application to Heroku

Deployment screen-3 — Deploy Node.js application to Heroku

Once you have done this process, Heroku starts building our application and deploys as well. After deployment is finished then your application will be access at https://anillabs.herokuapp.com/

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>