Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# nvm lazy loading to prevent zsh loading delays on macOS (inspired by @insidewhy)
# Add this to the end of your ~/.zshrc but make sure to remove all existing nvm.sh related code from ~/.zshrc first.
NVM_SH=""
# nvm.sh location depends on installation method
if [ -s "/usr/local/opt/nvm/nvm.sh" ]; then # Homebrew installer location
NVM_SH="/usr/local/opt/nvm/nvm.sh"
elif [ -s " ~/.nvm/nvm.sh" ]; then # Direct installer location
NVM_SH="~/.nvm/nvm.sh"
fi
if [ ! -z "$NVM_SH" ]; then
export NVM_DIR="~/.nvm"
nvm_cmds=(nvm node npm)
for cmd in $nvm_cmds ; do
alias $cmd="unalias $nvm_cmds && unset nvm_cmds && . $NVM_SH && $cmd"
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment