How to deploy your node.js project on Heroku
Follow the following steps:
- Create a Heroku account by signing up on herok website:https://www.heroku.com/
- Install the Heroku CLI on your machine:https://devcenter.heroku.com/articles/heroku-cli
- After installing Heroku CLI, login using the Heroku CLI by typing the following command:
heroku login
- Provide the credential you used to sign up on Heroku if it asks. Now your project can be push 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"
}
Check the package.json file
- Initiating your project using git init and deploying on herkou
git init
git add .
git commit -m "ready to deploy on heroku"
heroku create
git push heroku master
heroku open
CONGRATULATONS! Now you project is running on Heroku web server