A bunch of useful commands for various tools used for web development.
nvm : https://github.com/nvm-sh/nvm
nvm-windows : https://github.com/coreybutler/nvm-windows
Install the latest NodeJS version :
nvm install node
Install a specific version :
# List available versions
nvm ls-remote
nvm install $version
Temporarily change the used version :
nvm use $version
nvm run node --version
Permanently change the used version :
# Set latest
nvm alias default node
# Set specific
nvm alias default $version
Install the most recent NPM version for the current Node version :
nvm install-latest-npm
PM2 : https://pm2.keymetrics.io/docs/usage/quick-start/
Install PM2 :
npm install pm2@latest -g
Add a new app to PM2 & run it :
pm2 start index.js
pm2 start index.js --name $name
pm2 start index.js --watch # real-time reload
Run an app with a specific NodeJS version (through nvm) :
sudo pm2 start --name $name index.js --interpreter="/home/$user/.nvm/versions/node/$version/bin/node"
Generate an auto-startup file, and save currently running apps to the config :
pm2 startup
pm2 save
Manage PM2 apps :
pm2 list
pm2 restart $name_or_id
pm2 reload $name_or_id
pm2 stop $name_or_id
pm2 delete $name_or_id
Show the starting command used for an app, and NodeJS info :
pm2 show $name_or_id
│ script path │ /path/to/app/index.js │
│ script args │ N/A │
│ interpreter │ node │
│ interpreter args │ N/A │
│ node.js version │ 10.23.0 │
│ node env │ N/A │
Display logs from all apps :
pm2 logs
# Display both INFO and ERROR logs
pm2 logs --merge
# Last X lines
pm2 logs --lines $number_of_lines
Display monitoring UI for all apps :
pm2 dash
Dry-run :
certbot renew --dry-run
Renew existing certifcates :
certbot renew
Check the list of currentlty running vhosts :
a2query -s
Add a certificate to a newly-created Apache2 vhost :
certbot --apache -d [domain]