Created
October 2, 2017 20:26
-
-
Save jhnsnc/ca2a02f16be0a4ff90d5548f7019c839 to your computer and use it in GitHub Desktop.
Snippet to install NVM and set it up with a stable version of Node/NPM
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
#------------------------------------------------------------------------------- | |
# Install NVM | |
#------------------------------------------------------------------------------- | |
echo -e "Installing nvm, our Node version manager..." true | |
NVM_DIR="$HOME/.nvm" | |
if [[ -e "$NVM_DIR" ]]; then | |
echo -e "Already installed. Moving on..." | |
else | |
# install Node Version Manager | |
git clone https://github.com/creationix/nvm.git "$NVM_DIR" && cd "$NVM_DIR" && git checkout `git describe --abbrev=0 --tags` | |
echo -e "Complete!" | |
fi | |
echo -e "Checking NVM version" | |
nvm --version | |
#------------------------------------------------------------------------------- | |
# Install Node/NPM via NVM | |
#------------------------------------------------------------------------------- | |
echo -e "Installing correct Node version and updated NPM..." true | |
NODE_VERSION="stable" # using nvm's language... | |
# load nvm command in the script | |
# will do this and more in the bash_profile for the users | |
source ~/.nvm/nvm.sh | |
# Install and use version using NVM | |
nvm install "$NODE_VERSION" | |
# Ensure we have the most recent version of npm | |
npm install npm -g | |
echo -e "Checking installed Node version" | |
node -v | |
echo -e "Checking NPM version" | |
nvm -v | |
echo -e "Complete!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment