To check how to deploy with Heroku-cli read here
-
create heroku account
- it's a cloud platform for hosting apps
- https://signup.heroku.com/
-
create application
- provide a name (it will be the url https://app-name.herokuapp.com)
-
Check if the project has these
- package.json is in the root of the project
- package.json contains a start script
"scripts": {
"start": "node server.js"
},
-
Go to the Deploy section in your heroku dashboard
-
Enable Automatic deploys. (This will ensure that every time any code is pushed/merged to the master/ main branch, it will automatically deploy to your heroku app)
- Create a new cluster on mongoDB atlas (Please remember your username, password when you create them the first time for your account)
-
That url will look something like this
mongodb+srv://manish:<password>@cluster0-st12d.mongodb.net/<dbname>?retryWrites=true&w=majority
-
Change
<password>
with your real password and<dbname>
with the database name you need for your project -
It will then look like this
mongodb+srv://manish:Test@123@cluster0-st12d.mongodb.net/secondProject?retryWrites=true&w=majority
-
copy this mongodb url and save it somewhere
-
configure app
-
To deploy
$ git add
&&$ git commit
$ git push origin master
-
If your application isn't deployed successfully do
$ heroku logs
$ heroku logs -t