use nvm, stay sane
as web developers, we are mostly working on different projects. using npm
in almost all of them is a ritual. the problem comes when two projects use different versions of node and we are faced with compatibility issues.
a fullproof solution is to use nvm
to use multiple versions of node on your computer.
here is a quick list of steps to set it up and go la-la:
- install
nvm
(wow). here is cURL command to do that:
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash
2. check for installation
command -v nvm
this should output ‘nvm’ if the installation was successful. if not, close and open a new terminal and try again.
3. install node
nvm install node
this will install latest version of node. you can specify which version to install and install multiple versions. eg.
nvm install 6.10.2
4. in any new folder, you can specify to use whichever version you want
nvm use node
or
nvm use v6.10.2
or to use system default global version
nvm use system
5. to see a list if all the installed versions
nvm ls
6. finally, to uninstall a version if you no longer need it
nvm uninstall 6.10.2
this gives you a quick idea on how to manage your node versions without going insane.