What uses / respects the .node-version file?

wisew picture wisew · Dec 11, 2014 · Viewed 17.5k times · Source

I've searched Stack Overflow and GitHub (for both node and nvm) for an answer, but to no avail.

In some repos (like GitHub's Atom text editor, for instance), I've come across a .node-version file. It seems to be analogous to the .ruby-version standard file that works with any Ruby version manager to set the current version of Ruby correctly for the project.

But as far as I can tell from its documentation, nvm (Node Version Manager) only respects a .nvmrc file - it mentions nothing about a more general .node-version file. And there's no mention of .node-version in node's documentation (and I wouldn't expect there to be, since it doesn't ship with a version manager out of the box). I'm not aware of any other node version manager in heavy use.

So my question is, what is .node-version? What tools actually use it? Is it just an alias for .nvmrc, or am I missing something here?

Answer

LJHarb picture LJHarb · Apr 9, 2015

(disclosure: I maintain http://nvm.sh)

The most-used version managers for node are without a doubt nvm, nave, and n.

nvm is for modifying individual shell sessions to use the version you want. nave is for launching subshells with the version you want loaded. n is for switching a single system-wide version of node.

nvm uses a .nvmrc file, which like .ruby-version, contains the version-ish string X you'd normally couple with nvm use X or nvm install X. nvm use or nvm install by itself will locate the .nvmrc file, as will simply sourcing nvm upon opening a new shell.

It appears nave supports a .naverc file, but I'm not too familiar with its usage.

n doesn't appear to support any such config, but as it's system-wide, it doesn't really make as much sense to do so.


avn supports .node-version and attempts to provide automatic version switching by hooking into cd, after nvm decided that was too invasive a behavior to include.