my-env/install/nodejs

27 lines
663 B
Bash
Executable File

#!/bin/bash
##makedesc: Install nodejs + npm via nvm
echo
echo "==============================================="
echo "Installing nodejs..."
echo "==============================================="
echo
installed() {
command -v "$1" >/dev/null 2>&1
}
installed "nvm" && sudo apt install -y --autoremove nodejs npm nvm
! installed "nvm" && wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
nvm install-latest-npm
nvm install node
nvm use node
installed "node" && nvm current
nvm ls