First thing is initialize new git repository to your project using command
cmd:- git init
you can see: Initialized empty Git repository in E:/blogger/JobPreparation/PracticalProject/Server/.git/
Now time to add .Gitignore file to our project
create .gitignore file to our project root directory and add files name which you don't want to add in git
# dependencies
/node_modules
# misc
.env
cmd:- git init
you can see: Initialized empty Git repository in E:/blogger/JobPreparation/PracticalProject/Server/.git/
Now time to add .Gitignore file to our project
create .gitignore file to our project root directory and add files name which you don't want to add in git
# dependencies
/node_modules
# misc
.env
NOTE: Make sure you have added process.env.PORT || 3030 inside server
other wise it will cause problem in future.
Now add all files to git using command
cmd: git add .
and you can check status using command
cmd: git status
Now commit all changes using command
cmd: git commit -m "starter server with authentication"
make sure you have added start script to package.json file
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node server.js"
},
"engines": {
"node": "13.5.0" , // your node version : node -v
"npm" : "6.13.4" // your npm version: npm -v
},
again add it to git and commit changes
Now install heroku on device using command
npm i -g heroku
and then write command
For login
cmd: heroku login
After that create new app using command
cmd: heroku create
Then deploye your server using
cmd: git push heroku master
It will give you up and running server with it's URL.
You can also check log using
cmd: heroku logs