Skip to main content

137. LTS Node.js Version by Default

Status: Accepted Date: 2025-07-06

Context

When setting up a new development environment with NVM, we need to decide which version of Node.js to install and set as the default. We could choose the absolute latest version, a specific hardcoded version, or the latest Long-Term Support (LTS) version.

Using the latest version can introduce instability, as it may contain new features with undiscovered bugs. Hardcoding a specific version makes the automation brittle and requires frequent updates to keep it current.

Decision

Our 07_nodejs Ansible role will, by default, install the latest available Long-Term Support (LTS) version of Node.js and set it as the default alias in NVM.

This is accomplished by using the lts/* alias provided by NVM when installing. This policy prioritizes stability and broad compatibility, which are the key characteristics of the Node.js LTS releases. These versions are recommended for most users and production environments.

While LTS is the default, the Ansible role will also support installing other specific versions if needed, allowing for flexibility while still promoting a stable default.

Consequences

Positive:

  • Stability: By defaulting to an LTS version, we are choosing a version of Node.js that is stable, well-tested, and guaranteed to be maintained for an extended period. This provides a solid and reliable foundation for our development and production environments.
  • Broad Compatibility: LTS versions are designed to be compatible with the widest range of packages in the ecosystem. This reduces the likelihood of encountering dependency issues.
  • Low Maintenance: The lts/* alias in NVM means our Ansible role doesn't need to be updated every time a new version of Node.js is released. It will automatically pick up the latest LTS version, making the automation more robust and less brittle.

Negative:

  • Not on the Bleeding Edge: We will not have the very latest features of Node.js as soon as they are released. We will have to wait for them to be included in a future LTS release.

Mitigation:

  • A Deliberate Trade-off: This is a conscious and deliberate trade-off. For the environments managed by this automation, we value stability and reliability far more than having access to bleeding-edge features. Developers who need a newer, non-LTS version for a specific project can easily install it themselves using nvm install <version>, as NVM itself is already installed and configured.