Skip to content

Instantly share code, notes, and snippets.

@MacKentoch
Last active July 16, 2017 17:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MacKentoch/42be82e7f34f03edcc018b80406ca0be to your computer and use it in GitHub Desktop.
Save MacKentoch/42be82e7f34f03edcc018b80406ca0be to your computer and use it in GitHub Desktop.

Installing Node using NVM on OSX

BEFORE STARTING

IMPORTANT: If you have previously installed node using HomeBrew, ensure that you uninstall it before you proceed:

brew uninstall --force node

To install NVM, clone to the Git repository

git clone git://github.com/creationix/nvm.git ~/.nvm
 printf "\n\n# NVM\nif [ -s ~/.nvm/nvm.sh ]; then\n\tNVM_DIR=~/.nvm\n\tsource ~/.nvm/nvm.sh\nfi" >> ~/.bashrc
 NVM_DIR=~/.nvm
 source ~/.nvm/nvm.sh

ON OSX if you may encouter the error nvm not found,

open ~/.bash_profile

and add this:

source ~/.bashrc

Once complete, check which version of of nvm has been installed

nvm --version

now install any node version:

nvm install 5.7.0
nvm install 5.5.0
nvm install 5.3.0
nvm install 4.2.0
nvm install 0.12

migrate global packages while installing

nvm install node --reinstall-packages-from=node

TIP: switch between different versions of node:

nvm use 0.12

TIP: set default node version

nvm alias default v6.11.1

TIP: check which versions of node are available in your nvm instance:

nvm ls

TIP: set .nvmrc

You can create a .nvmrc file containing version number in the project root directory (or any parent directory). nvm use, nvm install, nvm exec, nvm run, and nvm which will all respect an .nvmrc file when a version is not supplied.

echo "6.11" > .nvmrc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment