NVM or N

From time to time I go back to the problem of switching Node.js versions. Sometimes it's enough to just go to the node.js website and install a new version but if you have to switch versions between different projects all the time then you soon realize you need a tool for that.

I know of two such tools:

  1. https://github.com/tj/n
  2. https://github.com/creationix/nvm

N has really nice UX and it's really intuitive to work with it. The problem arises if your different projects use different versions of global packages - you have to deal with it yourself.

The biggest advantage of NVM is that it switches global packages with the node version so you really get a clean slate with every version. The biggest problem I have with NVM is that it's UX is really bad and I found myself explaining the same things over and over again to my colleagues.

Because of the global packages, I found myself advising NVM to people last couple of years...

At the same time, I have learned the hard way that global dependencies are causing much more problems than the necessity of NVM. All projects that have used global dependencies were really hard to setup and those dependencies create a lot of problems in the long run.

It took me some time to add those to facts together. Basically switching global packages should not be necessary!

Even for complicated projects it's not really that hard to add all dependencies to packages.json. I've done that multiple times end the cost of slightly longer installation is nothing in comparison to how much easier it is to introduce a new person or to go back to the project after a couple of months.

So what's my advice?

  1. Add all your dependencies to package.json
  2. Try using "n"
  3. Switch to "nvm" if you encounter any issues

Feedback? Are you using something else?

Share on Hacker News
Share on LinkedIn

← Home

Want to learn more?

Sign up to get a digest of my articles and interesting links via email every month.

* indicates required

Please select all the ways you would like to hear from Krzysztof Kula:

You can unsubscribe at any time by clicking the link in the footer of my emails.

I use Mailchimp as a marketing platform. By clicking below to subscribe, you acknowledge that your information will be transferred to Mailchimp for processing. Learn more about Mailchimp's privacy practices here.