Managing Node.js Versions with nvm
A while back I wrote a blog post called Upgrade Node.js with NPM. The shell commands within that post work great but there were reports in the comments that it could mess with node module paths and such -- a far from ideal situation. Little did I know that I was only off by one letter: nvm is the ideal solution.
You can read the installation steps on the nvm GitHub page. There are only two easy steps for installation and configuration.
If you work with a lot of different Node.js utilities, you know that sometimes you need to quickly switch to other versions of Node.js without hosing your entire machine. That's where you can use nvm to download, install, and use different versions of Node.js:
nvm install 4.0
At any given time you can switch to another with
nvm use 0.12
If you want to check out what versions of Node.js are installed on your machine, you can use the
nvm ls /* v0.10.26 v0.10.36 -> v0.12.7 v4.2.1 system */
If you're done with a version and want it gone, you can do that too:
nvm uninstall 0.10
Set the Default Node Version
You can set the default Node.js version by using
nvm alias default system # or... nvm alias default v9.3.0
nvm has been a lifesaver for me, especially when troubleshooting issues in projects where the user may have more than one Node.js version. If you're looking to get into Node.js development, one of the first tools you get should be nvm!
Aliasing is quick important especially when it comes to default:
Also not that there is a similar tool for windows users.
You can also check [my fork](https://github.com/yoannmoinet/nvmw) which will persist your choice across session and reboots.
is useful for moving your tools to the new Node.js version.
See usage: https://github.com/creationix/nvm#usage
I’ve been using nvm for almost two years now and really really like it. Very easy to use and very compatible across Mac and RedHat.
Is this a replacement for nodenv which I never really got the hang of?
I agree with Kyle. Been using it for a couple years as well and I like it a lot too!
I always had problem with nvm. I’d suggest n https://github.com/tj/n instead :)
Thanks for the nvm primer; it’s been a while and I done fergot. BTW, for installs, updates and dependencies, I do things concentrically:
Self > OS X
OS X > Homebrew
Homebrew > node
Homebrew > nvm
Since nvm manages node I don’t use npm to administer with it.
I am trying to install it. But getting err in my Windows OS