shell/install/nodejs

28 lines
658 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
2023-04-11 15:43:14 +00:00
echo "Finish!"
nvm current
nvm ls