How to install Node.js using Node Version Manager

Node Version Manager (NVM) lets you install multiple versions of Node.js to your local user directory, enabling easy upgrades and version switching, without the permission troubles that are common with non-NVM setups.

  • Uninstall any previous Node.js versions you may already have
  • Install NVM by running the following in Terminal:
    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
    
  • Install Node.js by running the following in Terminal:
    nvm install node
    nvm alias default node
    nvm use node