This article explains how to deploy your Express.js application live in your own production environment.
Initialize a Git repository and commit your changes
Before you can deploy your app to Heroku, you need to initialize your folder as a Git repository and commit your application code to the Git repository.
# Initialize an empty Git repository git init # Stage and commit the most recent work on the main or master branch git add . git commit -m 'Write a clear meaningful commit message here'
Deploy the app to Heroku
You can deploy your app to a live production environment with Heroku. If you don't already have one, create a Heroku account., Then log in to Heroku from the terminal:
Create a new Heroku application:
Add Heroku as a git remote, so you can push your project to Heroku:
# Add Heroku remote heroku git:remote -a <name-of-the-newly-created-app> # Check the remotes available # Newly added `heroku` remote repository connection should be shown git remote -v
Deploy your project to Heroku:
# Push the commit and update the deployed version on Heroku git push heroku master
Open the app in the browser:
# Open the app in the browser heroku open
Now your site is online!
Was this article helpful?
Can't find what you're looking for? Get in touch with us on our Community Forum.