Using nvm To Manage Node Versions

Different projects of node use different versions and being able to switch back and forth is a necessity. Luckily for us, there is nvm which allows to change and install different nvm versions easily. Here is how to get started and some quick commands.

Installing

brew update
brew install nvm
source $(brew --prefix nvm)/nvm.sh
# Run this to not have to run the shell script on every terminal start
echo "source $(brew --prefix nvm)/nvm.sh" >> ~/.profile
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash

Commands

nvm install 10.10.0
nvm ls-remote
nvm use v8.6.0

Using a .nvmrc file

echo "10.10.0" > .nvmrc

With deeper shell integration you can have your node version change immediately when changing into that directory that contains a .nvmrc file. This makes changing node versions based on the project a breeze and totally automated.

Read more about nvm

Instagram Post