If you’ve payed any attention to Node.js world, you are likely aware of the whole Node.js & io.js fiasco where they forked & diverged & then agreed to come back together. I wrote a little about it back in May of this year: The Past, Present & Future of Node.js and io.js.
Earlier this week they annoucned the reconcilation project is complete and they are together as Node.js v4.0.0! Great news indeed however there are plenty of things built on Node that still look for specific versions or might see v4 as a legacy version.
So should you upgade your Node install from the current v0.12.* version you’re running to the latest version? I did… but I want to be able to go back to an older version if there are issues with something I need to use.
Run Multiple Node Versions with Node Version Manager (NVM)
To do this, I use NVM: Node Version Manager. It allows you to install multiple versions of Node.js or io.js and then jump between different versions for your current active version.
While NVM is specific to OSX, there are Windows options. Check out the repo for details on this.
You can follow the script in their readme in the repo, but I preferred to install it using Homebrew. You install NVM using the simple command
brew install nvm. Now there’s some additional setup stuff you should run though… it’s all spelled out for you if you run
brew info nvm as you need to create a folder for NVM, copy some stuff into it and update your shell’s config file.
With NVM installed, let’s see what version of node we’re running. When I ran
node -v it said I was running v0.12.7 which was the last production version of Node before v4 shipped… but I’m not running it through NVM. How do I know that? Because when I ran
nvm -ls it told me that both Node & iojs were running version N/A.
Let’s get some versions installed. To see what’s available, run
nvm ls-remote and watch it fly by… tons of options! So let’s install three versions:
nvm install v0.12.6 nvm install v0.12.7 nvm install v4.0.0
NVM automatically sets your current Node version to the last one you installed so if you run
node -v you will see v4.0.0. Switch back to a previous version by running
nvm use v0.12.7 and now the results of
node -v will say v0.12.7! Easy eh?
Want to see what you have installed?
nvm ls will tell you and even point to the current version.
Using this little tool you can upgrade without fear and have the ability to jump back in time to an older version.comments powered by Disqus