-
-
Save peterlazar1993/1ee7dbd65add9dbddded5c76a7b00a35 to your computer and use it in GitHub Desktop.
script as alias for node to use node via nvm
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
#!/usr/bin/env sh | |
# Use the version of node specified in .nvmrc to run the supplied command | |
export NVM_DIR="$HOME/.nvm" | |
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm | |
nvm_rc_version > /dev/null 2> /dev/null | |
HAS_NVM_RC=$? | |
if [[ "$HAS_NVM_RC" == "0" ]] ; then | |
nvm run $* | |
else | |
nvm run default $* | |
fi | |
exit $? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The above script is useful to run node in environments where user shell is not loaded, for eg. xcode run scripts phase
Place this as
/usr/local/bin/node
Make sure to set right permissions to make it executable -
sudo chmod +x /usr/local/bin/node