shell/install/997-nodejs.sh

29 lines
656 B
Bash
Raw Normal View History

#!/bin/bash
2022-01-08 06:40:30 +00:00
echo
echo "==============================================="
echo "Installing nodejs..."
echo "==============================================="
echo
2022-01-08 06:40:30 +00:00
installed() {
command -v "$1" >/dev/null 2>&1
}
# sudo apt install -y --autoremove nodejs npm
if !installed "nvm"; then
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash
fi
2022-01-08 06:40:30 +00:00
if [ $(nvm current) == 'system' ]; then
2022-01-08 06:40:30 +00:00
echo "WARNING: You already have node installed - removing to install actual version"
sudo apt remove -y --autoremove nodejs npm
else
nvm install-latest-npm
fi
2022-01-08 06:40:30 +00:00
nvm install node
nvm use node
2022-01-08 06:40:30 +00:00
installed "node" && nvm current
nvm ls