Skip to content

Instantly share code, notes, and snippets.

@yunyuyuan
Created September 21, 2023 01:29
Show Gist options
  • Save yunyuyuan/0a6d8af6d6b2a65d93d247ad834d144c to your computer and use it in GitHub Desktop.
Save yunyuyuan/0a6d8af6d6b2a65d93d247ad834d144c to your computer and use it in GitHub Desktop.
nvm setup
lazy_load_nvm() {
unset -f npm node nvm
export NVM_DIR=~/.nvm
[[ -s "$NVM_DIR/nvm.sh" ]] && source "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && source "$NVM_DIR/bash_completion"
}
npm() {
lazy_load_nvm
npm $@
}
node() {
lazy_load_nvm
node $@
}
nvm() {
lazy_load_nvm
nvm $@
}
if [ -f ".nvmrc" ]; then
nvm use > /dev/null
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment