Skip to content

Instantly share code, notes, and snippets.

@lostrouter
Last active August 29, 2015 14:24
Show Gist options
  • Save lostrouter/695fb94cf7510fae77c9 to your computer and use it in GitHub Desktop.
Save lostrouter/695fb94cf7510fae77c9 to your computer and use it in GitHub Desktop.
bash script wrapping nvm to provide almost certain way to use specified version of node
#!/bin/bash
if [ "$#" -ne 1 ]; then
echo "incorrect usage"
echo "Usage:"
echo " SetNodeVersion <VERSION>"
exit -1
fi
NODE_VERSION=$1
export NVM_DIR="${HOME}/.nvm"
[ -s "${NVM_DIR}/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
nvm use ${NODE_VERSION} || nvm install ${NODE_VERSION}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment