First create a simple node.js application, if you don't have a node application you can try this demo application. To run the demo application you need to connect it with your MongoDB database.
- Create a Heroku account by signing up on herok website:https://www.heroku.com/
- Install the Heroku CLI on your computer:https://devcenter.heroku.com/articles/heroku-cli
- After installing Heroku CLI, login using the Heroku CLI by typing the following command on command prompt or terminal:
heroku login
- Provide the credential you used to sign up on Heroku if it asks. Now your project can be pushed to heroku server using git from your computer terminal
- The package.json scripts should have scripts and the "start" should be the "node sever.js". As shown below
"scripts": {
"start": "node server.js"
}
- Initiating your project using git, init and deploying on herkou
git init
git add .
git commit -m "ready to deploy on heroku"
heroku create your-app-name
git push heroku master
heroku open
CONGRATULATONS!
Now you project is running on Heroku web server