my-env/install/nodejs

31 lines
698 B
Plaintext
Raw Normal View History

#!/bin/bash
##makedesc: Install nodejs + npm via nvm
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