Skip to content

Instantly share code, notes, and snippets.

@Vishal1297
Created September 28, 2022 10:41
Show Gist options
  • Save Vishal1297/89008bf7d833d3f5520431042f48c15c to your computer and use it in GitHub Desktop.
Save Vishal1297/89008bf7d833d3f5520431042f48c15c to your computer and use it in GitHub Desktop.
Remove node from apt & install latest stable from node source.
#!/bin/bash
node_v=$1
if [ -z "$1" ]
then
echo "Using default stable version 16.x"
node_v="16"
fi
sudo apt remove nodejs -y && sudo apt purge nodejs -y
sudo apt autoremove -y
# Install specific node version
node_source="https://deb.nodesource.com/setup_${node_v}.x"
sudo curl -sL "${node_source}" | sudo -E bash -
sudo apt install nodejs
# To update node to lastest stable version
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment