Deploy Node.js on ubuntu with GIT

Install Git on your server

ssh into your VM, then install Git:

Clone your private/public repo

Remove old node and add new node

Install pm2

Kill other PM2 Process

Create an environment variable file

Update the local repo

If you get permission denied error which might happen if the repo is private follow the following steps

Run PM2

For automatic deployment, u can follow the following methods

  • Github actions (CI & CD)
  • post-receive Git hook

Finding Magic.