2021-12-22 13:51:22 +00:00
|
|
|
#!/bin/bash
|
2022-07-04 09:56:45 +00:00
|
|
|
##makedesc: Install nodejs + npm via nvm
|
|
|
|
|
2022-01-08 06:40:30 +00:00
|
|
|
echo
|
|
|
|
echo "==============================================="
|
|
|
|
echo "Installing nodejs..."
|
|
|
|
echo "==============================================="
|
|
|
|
echo
|
2021-12-22 13:51:22 +00:00
|
|
|
|
2022-01-08 06:40:30 +00:00
|
|
|
installed() {
|
|
|
|
command -v "$1" >/dev/null 2>&1
|
|
|
|
}
|
|
|
|
|
|
|
|
# sudo apt install -y --autoremove nodejs npm
|
2021-12-22 13:51:22 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
2021-12-22 13:51:22 +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"
|
2021-12-22 13:51:22 +00:00
|
|
|
sudo apt remove -y --autoremove nodejs npm
|
|
|
|
else
|
|
|
|
nvm install-latest-npm
|
|
|
|
fi
|
2022-01-08 06:40:30 +00:00
|
|
|
|
2021-12-22 13:51:22 +00:00
|
|
|
nvm install node
|
|
|
|
nvm use node
|
2022-01-08 06:40:30 +00:00
|
|
|
installed "node" && nvm current
|
2021-12-22 13:51:22 +00:00
|
|
|
nvm ls
|