my-env/install/nodejs

27 lines
663 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
}
2022-12-21 14:07:05 +00:00
installed "nvm" && sudo apt install -y --autoremove nodejs npm nvm
2022-12-21 14:07:05 +00:00
! installed "nvm" && wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash
2022-01-08 06:40:30 +00:00
2022-12-21 14:07:05 +00:00
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
2022-01-08 06:40:30 +00:00
2022-12-21 14:07:05 +00:00
nvm install-latest-npm
nvm install node
nvm use node
2022-01-08 06:40:30 +00:00
installed "node" && nvm current
nvm ls