Last active
November 14, 2020 10:01
-
-
Save a2ron/c1ef8609ff1bca5f2687dd869f11061f to your computer and use it in GitHub Desktop.
Load NVM on demand
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export NVM_DIR="$HOME/.nvm" | |
# Default node version | |
alias node="$HOME/.nvm/versions/node/v8.11.1/bin/node" | |
# Function to load the original nvm and execute it | |
load_and_exec_nvm(){ | |
unalias node | |
unalias nvm | |
echo "Loading NVM..." | |
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm | |
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion | |
echo "Executing NVM..." | |
nvm $@ | |
} | |
# Default nvm, the wrapper to load it and execute it | |
alias nvm="load_and_exec_nvm" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This snippet let you load NVM just when you need it, in order to save time and resources.
It also set a default node version, just in case.