Created
September 28, 2022 10:41
-
-
Save Vishal1297/89008bf7d833d3f5520431042f48c15c to your computer and use it in GitHub Desktop.
Remove node from apt & install latest stable from node source.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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