Install Heroku CLI
Login with browser
Deploy to Github
Status of git
need to use git add to add to staged changes tracked files but with unstaged changes git add — add untracked files to staged changes
Create a git for current project
Create a git ignore file
Check git status again to see node_modules are not included in untracked files
Add files or folder to commit:
To remove files from staged changes:
To add staged files to commit:
This code is still not pushed to GitHub. Don’t check!!! =))))
Create a SSH Key:
This will create a ssh folder under user folder, with an id_rsa key file:
Make sure that our SSH agent is running
Register SSH Key
Now we can push our code to Git Hub.
Create a repo on Github
Link existing local source code as origin
Add SSH Key to Github
name: our source origin (laptop or server)
Check SSH connection to GitHub
This mean Github allow our origin to connect to GitHub via SSH and public key above
Really push code to Github Repo
Done on the Github part.
Deploy to Heroku
Add SSH Key
Create a new app
In order to run the app, we need to specify
change listening port in express change all absolute path to relative paths
We need to modify package.json to change starting script
Then locally we can use npm run start to run node app.js We need to modify port in express
We need to change to local fetch to relative paths
Then push changes to Github again:
Check connection between git and heroku
Push main to heroku server
Prepare a build script only for local and for other developers
In this case, nodemon is a global module. We need to convert it to developer module.
Uninstall global module
Install dev module
Heroku will never use nodemon locally save-dev module can only run within script define in package.json