We no longer use non-deterministic versions like lts/gallium
. This is not supported by all tools. In particular
asdf
Show archive.org snapshot
is sunsetting its support for LTS aliases.
- Not all versions of Node.js are compatible with each other. Also npm packages may require a minimum or maximum version of Node.js. We [use nvm](https://makandracards.com/makandra/35715-install-node-js-npm-under-ubuntu-with-nvm) on our development PCs so we can operate multiple versions of Node.js in parallel.
- To make sure that all developers use a compatible version of Node.js, your Rails project should declare the required Node.js in a file called `.nvmrc`.
- When a `.nvmrc` exists, developers can `cd` in your project directory and activate the project's node version with
- ```text
- nvm use
- ```
- There are [some hacks](https://github.com/nvm-sh/nvm#deeper-shell-integration) to automatically activate a Node version as you `cd` into a directory, but I didn't test them. Note that these hacks might clash with `rbenv` which also aliases your `cd` to activate the correct Ruby version from `.ruby-version`.
- Picking the right Node version
- ========================
-We prefer using one of Node's [LTS release lines](https://nodejs.org/en/about/releases/), as they get minor updates over some year.- +We prefer using one of Node's [LTS release lines](https://nodejs.org/en/about/previous-releases), as they get minor updates over some year.
-For example, if we want to use Node 16 LTS, we would fill in its alias into our `.nvmrc`.- +For example, if we want to use Node 20 LTS, we would look up its latest release and fill in:
- ```text
-lts/gallium- +20.11.1
- ```
- > [warning]
-> While some package managers like `asdf` also support the notation `lts-gallium` (with a dash), NVM only supports `lts/gallium`.- +> Don't use a nondeterministic version like `lts/gallium`. This is not supported by all tools. In particular [asdf](https://github.com/asdf-vm/asdf-nodejs) is sunsetting its support for LTS aliases.
- Testing compatibility
- ---------------------
- In general, a recent Rails projects should use the currently active LTS version of LTS.
- If you are unsure about compatibility, these two commands should work:
- ```text
- yarn
- rake assets:precompile
- ```