| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Q: Is .node-version read by multiple Node.js version managers?
A: Yes.
Q: Does .node-version have a defined common or standard file format?
A: No.
Q: So what compatibility is there across individual products?
A: Good question! Read on...
Version managers for Node.js which read a .node-version file include (in alphabetical order):
Other products which use .node-version include:
(Note: nvm does not support reading a .node-version file. See #4 for more.)
If you are creating the file, a format with full compatibility across current tests is:
A leading 'v' is widely supported, so this will work with most implementations:
$ node --version
v20.12.0
$ node --version > .node-versionIf you are reading the file in a new implementation, I suggest you also support optional leading v and any line ending. Allowing a leading v is common and gives nice symmetry with node --version. Allowing any line ending makes it easier for users and especially Windows users to create a file compatible with your product.
| Utility | simple | leading v | partial | Unix EOL | No EOL | Win EOL | Notes |
|---|---|---|---|---|---|---|---|
| 20.5.0 | v20.5.0 | 20.5 | |||||
| asdf | ✅ | ✅ | ❌ | ✅ | ✅ | ❌ | |
| aube | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | |
| chnode | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | |
| dev | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | |
| direnv | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | |
| fnm | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | |
| mise | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | |
| n | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | |
| nodeenv | ✅ | ✅ | ❌ | ✅ | ✅ | ✅ | |
| nenv | ✅ | 🧩 #8 | 🧩 #8 | ✅ | ✅ | ✅ | |
| nodenv | ✅ | ✅ | 🧩 #1 | ✅ | ✅ | ✅ | |
| nodist | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | |
| nub | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | |
| nve | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | |
| nvm.fish | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | |
| nvs | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | |
| setup-node | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | |
| Vite+ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | |
| vfox | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
The columns show whether the utility supports a file containing:
The compatibility table deliberately only covers commonly supported formats and is not intended to be a full feature table.
Some utilities do support version specifiers beyond just a numeric version. Often utilities read the .node-version file contents and then use their normal version parsing code. Some recognise Node.js codenames (like Jod), or convenience targets like lts.
There is not wide support for comments in the .node-version file, whether on the same line or a separate line.
For interest, here are discussion about similar .ruby-version file format. The commonly supported format is a simple version, with many products adding fuzzy matching. (Ruby is likely the inspiration for some of the .node-version usage, especially nodenv which uses rbenv syntax.)
A discussion about a possible standard format for .node-version was started in 2016 initially covering desirable (new) features and then more focus on existing usage, but did not reach consensus.
StackOverflow: What uses / respects the .node-version file?
| Back | FazBrowse Home | New Git URL |