Node.js – `NVM` vs `N`

I recently started doing an online course on “MEAN” applications for fun. If you’re not familiar, MEAN stands for Mongo, Express, Angular, Node. It’s pretty neat to see the kinds of things that you can throw together. I still don’t think I’d write something for production that uses Node.js, but other people have had good experience with it.

While doing my learning, the course recommended not to just install node, but to install it with nvm, n or something similar. I could guess by the name that they’re similar to rvm and things similar to rvm (which I finally got around to learning about), but that was about it.

I wanted to know the differences between them, and was hoping someone else had already done the work, but unfortunately googling “nvm vs n” didn’t yield the best results. The most useful article I could find was this. Unfortunately, it was only partially informative – it taught me more than I knew before, but I was interested in learning some of the finer details. So I thought it warranted playing with them both.

Both N and NVM are just node.js version managers. That’s it. They won’t magically write your projects for you, but they can help you keep things separated when working on multiple projects, which as we all know happens too often.


Github link

N is pretty easy to get installed. First you install node.js, then you run  npm install -g n. The irony is not lost on me that you must first install node in order to install the node manager.

The way N works is it installs the n executable to your path. You then use it to install different versions of node.

and you can switch between them just by running  n and picking the version you want from a list.

Here’s where things get tricky.

N works by storing different versions of node in some directory somewhere and when you switch versions, it will copy it to  /usr/local/bin. This is great for simplicity. It’s easy to install, easy to use, the only problem is that you basically have to  sudo every command.

Also, because it’s just swapping out different versions of node from your install directory, it doesn’t have a good way of handling those pesky npm install -g packages.

If you install something globally, then switch out versions of node, you may be left confused as to why things aren’t working.


Github link

NVM works a little differently. To install it, run

It might not install itself quite right in os x, so you may need to check to make sure it put this in your ~/.bash_profile

on my machine, it put that in  .bashrc even though that file doesn’t work in os x.

Then you need to restart your terminal to get your path working, and you can start installing node versions like this

When NVM installs versions of node, it works a lot more like RVM. NVM installs node to ~/.nvm/<version>/. Then it modifies your PATH to include the proper bin directory.

This does make things slightly more complicated than it does with N, but it does grant one benefit. When installing global packages, they too get installed under  ~/.nvm/<version>. So if you’re working on two different projects and each of them needs a version of karma-cli, you can be sure you’re using the proper version. Now node is still fairly new, so there aren’t that many versions of the different packages that tend to be installed globally, but give it time, you never know what will happen.

The only thing that NVM is missing in my mind is an equivalent to RVM’s gemsets.

1 thought on “Node.js – `NVM` vs `N`”

Leave a Comment

Your email address will not be published. Required fields are marked *