├── .gitignore ├── LICENSE ├── README.md └── fixtures ├── eol-lin └── .node-version ├── eol-none └── .node-version ├── eol-win └── .node-version ├── partial └── .node-version ├── simple └── .node-version └── vsimple └── .node-version /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 John Gee 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # .node-version File Usage 2 | 3 | Q: Is `.node-version` read by multiple Node.js version managers? 4 | A: Yes. 5 | 6 | Q: Does `.node-version` have a defined common or standard file format? 7 | A: No. 8 | 9 | Q: So what compatibility is there across individual products? 10 | A: Good question! Read on... 11 | 12 | ## Supporting Products 13 | 14 | Version managers for Node.js which read a `.node-version` file include (in alphabetical order): 15 | 16 | - [asdf-nodejs](https://github.com/asdf-vm/asdf-nodejs) Node.js plugin for asdf version manager. (macOS, Linux) 17 | - [avn](https://github.com/wbyoung/avn) Automatic Version Switching for Node. (macOS, Linux) 18 | - [chnode](https://github.com/tkareine/chnode) Changes shell's current Node.js version by updating $PATH (macOS, Linux) 19 | - [dev](https://docs.pkgx.sh/using-dev/dev) `dev` is built on [pkgx](https://docs.pkgx.sh), a single, standalone binary that can run anything (macOS, Linux) 20 | - [direnv](https://github.com/direnv/direnv) unclutter your .profile. (macOS, Linux) 21 | - [fnm](https://github.com/Schniz/fnm) 🚀 Fast and simple Node.js version manager, built in Rust. (macOS, Linux, Windows) 22 | - [mise](https://github.com/jdx/mise) Polyglot switcher compatible with asdf plugins, built in Rust. (macOS, Linux) 23 | - [n](https://github.com/tj/n) Interactively Manage Your Node.js Versions. (macOS, Linux) 24 | - [nenv](https://github.com/ryuone/nenv) Groom your app’s Node environment with nenv (macOS, Linux) 25 | - [nodeenv](http://ekalinin.github.io/nodeenv/) Virtual environment for Node.js & integrator with virtualenv (macOS, Linux, Windows) 26 | - [nodenv](https://github.com/nodenv/nodenv) Manage multiple NodeJS versions. (macOS, Linux) 27 | - [nodist](https://github.com/nullivex/nodist) Natural node.js and npm version manager for windows. (Windows) 28 | - [nve](https://github.com/ehmicky/nve) Run any command on specific Node.js versions (macOS, Linux, Windows) 29 | - [nvm-rust](https://github.com/BeeeQueue/nvm-rust) A cross-platform node version manager that doesn't suck (macOS, Linux, Windows) 30 | - [nvm.fish](https://github.com/jorgebucaran/nvm.fish) Node.js version manager lovingly made for Fish. (macOS, Linux) 31 | - [nvs](https://github.com/jasongin/nvs) Node Version Switcher - A cross-platform tool for switching between versions and forks of Node.js. (macOS, Linux, Windows) 32 | - [setup-node](https://github.com/actions/setup-node) ([configuration](https://github.com/actions/setup-node/blob/main/docs/advanced-usage.md#node-version-file)) Set up your GitHub Actions workflow with a specific version of node.js 33 | - [vfox](https://vfox.lhan.me) The Multiple SDK Version Manager 34 | 35 | Other products which use `.node-version` include: 36 | 37 | - [bitrise](https://bitrise.io) The CI/CD Platform built for Mobile DevOps 38 | - [Cloudflare Pages](https://developers.cloudflare.com/pages/platform/language-support-and-tools/#supported-languages-and-tools) Build fast sites. In record time. 39 | - [Hostman](https://hostman.com) Hosting platform that deploys your web applications 40 | - [netlify](https://docs.netlify.com/configure-builds/manage-dependencies/#node-js-and-javascript) Instantly build and deploy your sites to our global network from Git. 41 | - [paketo](https://paketo.io/docs/howto/nodejs/) Your app, in your favorite language, ready to run in the cloud 42 | - [preferred-node-version](https://github.com/ehmicky/preferred-node-version) Get the preferred Node.js version of a project or user 43 | - [Pulumi Deployments](https://www.pulumi.com/blog/docker-containers/) Automate, Secure, and Manage Everything You Run in the Cloud 44 | - [ReadyMage](https://help.readymage.com/project-development/node.js-version#node-version) Magento 2 and PWA managed auto-scalable infrastructure hosting service. 45 | - [render](https://render.com/docs/node-version) A Cloud for the New Decade 46 | - [Spaceship](https://spaceship-prompt.sh/sections/node/) Minimalistic, powerful and extremely customizable Zsh prompt 47 | - [starship](https://starship.rs/config/#nodejs) ☄🌌️ The minimal, blazing-fast, and infinitely customizable prompt for any shell! 48 | - [typescript-action](https://github.com/actions/typescript-action) Create a TypeScript Action with tests, linting, workflow, publishing, and versioning 49 | - [Vercel Conformance](https://vercel.com/docs/workflow-collaboration/conformance/rules/REQUIRE_NODE_VERSION_FILE) Conformance provides tools that run automated checks on your code for product critical issues, such as performance, security, and code health. 50 | - [VMware Tanzu](https://docs.vmware.com/en/VMware-Tanzu-Buildpacks/services/tanzu-buildpacks/GUID-nodejs-nodejs-buildpack.html) The Tanzu Node.js Buildpack supports several popular configurations for Node.js apps. 51 | 52 | (Note: [nvm](https://github.com/nvm-sh/nvm) does _not_ support reading a `.node-version` file. See [#4] for more.) 53 | 54 | ## Suggested Compatible Format 55 | 56 | If you are creating the file, a format with full compatibility across current tests is: 57 | 58 | - single line with unix line ending 59 | - three part numeric version e.g. 14.5.0 60 | 61 | A leading 'v' is widely supported, so this will work with most implementations: 62 | 63 | ```bash 64 | $ node --version 65 | v20.12.0 66 | $ node --version > .node-version 67 | ``` 68 | 69 | If you are reading the file in a new implementation, I suggest you also support optional leading `v` and any line ending. 70 | Allowing a leading `v` is common and gives nice symmetry with `node --version`. Allowing any line ending makes it easier 71 | for users and especially Windows users to create a file compatible with your product. 72 | 73 | ## Compatibility Testing 74 | 75 | | Utility | simple | leading `v` | partial | Unix EOL | No EOL | Win EOL | Notes | 76 | | :--- | :---: | :---: | :---: | :---: | :---: | :---: | :---: | 77 | | | `20.5.0` | `v20.5.0` | `20.5` | | | | | 78 | | [asdf](https://github.com/asdf-vm/asdf-nodejs) | :white_check_mark: | :white_check_mark: | :x: | :white_check_mark: | :white_check_mark: | :x: | | 79 | | [avn](https://github.com/wbyoung/avn) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :ghost: [#11] | 80 | | [chnode](https://github.com/tkareine/chnode) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | | 81 | | [dev](https://docs.pkgx.sh/using-dev/dev) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | | 82 | | [direnv](https://github.com/direnv/direnv) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | | 83 | | [fnm](https://github.com/Schniz/fnm) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | | 84 | | [mise](https://github.com/jdx/mise) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | | 85 | | [n](https://github.com/tj/n) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | | 86 | | [nodeenv](http://ekalinin.github.io/nodeenv/) | :white_check_mark: | :white_check_mark: | :x: | :white_check_mark: | :white_check_mark: | :white_check_mark: | | 87 | | [nenv](https://github.com/ryuone/nenv) | :white_check_mark: | 🧩 [#8] | 🧩 [#8] | :white_check_mark: | :white_check_mark: | :white_check_mark: | | 88 | | [nodenv](https://github.com/nodenv/nodenv) | :white_check_mark: | :white_check_mark: | 🧩 [#1] | :white_check_mark: | :white_check_mark: | :white_check_mark: | | 89 | | [nodist](https://github.com/nullivex/nodist) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | | 90 | | [nve](https://github.com/ehmicky/nve) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | | 91 | | [nvm-rust](https://github.com/BeeeQueue/nvm-rust) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | | 92 | | [nvm.fish](https://github.com/jorgebucaran/nvm.fish) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | | 93 | | [nvs](https://github.com/jasongin/nvs) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | | 94 | | [setup-node](https://github.com/actions/setup-node) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | | 95 | | [vfox](https://vfox.lhan.me) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | | 96 | 97 | [#1]: https://github.com/shadowspawn/node-version-usage/issues/1 98 | [#4]: https://github.com/shadowspawn/node-version-usage/issues/4 99 | [#8]: https://github.com/shadowspawn/node-version-usage/issues/8 100 | [#11]: https://github.com/shadowspawn/node-version-usage/issues/11#issuecomment-1509992826 101 | 102 | The columns show whether the utility supports a file containing: 103 | 104 | - simple: three part numeric version, like `20.5.0` 105 | - leading `v`: numeric version with a leading `v`, like `v20.5.0` 106 | - partial: numeric version with less than three parts, like `20.5` 107 | - EOL: end of line characters used in file, Unix `\n` or Windows `\r\n` or none 108 | 109 | ## References 110 | 111 | 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.) 112 | 113 | - 114 | - 115 | 116 | A discussion about a possible standard format for `.node-version` was started in 2016 initially 117 | covering desirable (new) features and then more focus on existing usage, but did not reach consensus. 118 | 119 | - 120 | 121 | StackOverflow: What uses / respects the .node-version file? 122 | 123 | - 124 | -------------------------------------------------------------------------------- /fixtures/eol-lin/.node-version: -------------------------------------------------------------------------------- 1 | 20.0.0 2 | -------------------------------------------------------------------------------- /fixtures/eol-none/.node-version: -------------------------------------------------------------------------------- 1 | 20.1.0 -------------------------------------------------------------------------------- /fixtures/eol-win/.node-version: -------------------------------------------------------------------------------- 1 | 20.0.0 2 | -------------------------------------------------------------------------------- /fixtures/partial/.node-version: -------------------------------------------------------------------------------- 1 | 20.4 2 | -------------------------------------------------------------------------------- /fixtures/simple/.node-version: -------------------------------------------------------------------------------- 1 | 20.3.0 2 | -------------------------------------------------------------------------------- /fixtures/vsimple/.node-version: -------------------------------------------------------------------------------- 1 | v20.5.0 2 | --------------------------------------------------------------------------------