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?
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.
Check your Node version in one step. Using npm to check your node version (and also update it) Managing your Node versions with nvm.
nvmrc file containing a node version number in your project. You can use the nvm —-help to check other options. After that you can simply run commands like nvm use, nvm install and nvm run etc. This will the default node. js version defined in .
The Node JS website states that “Production applications should only use Active LTS or Maintenance LTS releases” (Node JS org, 2020). This all means that if today you start learning with Node JS 16, you are good to deploy a production app with this version till March 2024.
(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.
There are a few version managers for node.js respecting .node-version
file:
There may be some other version managers, but I'm not aware of them.
I don't know which particular version manager Atom uses. nodenv have more stars on GitHub, but avn looks more mature and better maintained for me, not to mention its compatibility with both n and nvm.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With