shell-host/lang/nvm/nvm

22 lines
579 B
Bash

#!/bin/bash
echo adding nvm to shell
if [[ -f $NVM_SCRIPTS_DIR/init-nvm.sh ]]; then
mkdir -p $NVM_DIR
source $NVM_SCRIPTS_DIR/init-nvm.sh
fi
if command -v nvm >/dev/null 2>&1; then
# echo node version manager installed $NVM_DIR
if ! nvm use --lts >/dev/null 2>&1; then
echo a long term support version is not installed so installing $(nvm version-remote --lts)
nvm install --lts --latest-npm
nvm use --lts
echo current active version $(node --version)
fi
alias nvml="nvm use --lts"
alias nvmil="nvm install --lts --latest-npm"
alias nvmu="nvm use"
alias nvmls="nvm ls"
fi