Much like Ruby’s version manager, its best to get Nodejs Version Manager from the beginning if you’re going to be working with Node.
Node being actively under improvement is churning new versions quickly. Keeping up with different package requirements can be a mess even if you’re not dealing with multiple projects. And you probably need some serious help if you’re doing so. Which is where NVM comes in.
Uninstall System-wide Node
First off, if you have a system-wide installation, which you might want to get rid of, delete any node and node_modules directories from /usr/local/lib
and /usr/local/include
by running –
cd /usr/local/lib
sudo rm -rf node*
cd /usr/local/include
sudo rm -rf node*
cd /usr/local/bin
sudo rm -rf /usr/local/bin/npm
sudo rm -rf /usr/local/bin/node
Install NVM
- Run the installation script
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.29.0/install.sh | bash
You can get the latest version number on NVM’s github page. - Add the path to
.bash_profile
–
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
Install Node
Run nvm install X
where X
is a version number like “0.12”
Run
nvm use X
Happy system config, happy coding!