Skip to main content

138. Support for Multiple Package Managers

Status: Accepted Date: 2025-07-06

Context

The Node.js ecosystem has several popular package managers. While npm is the default manager that comes with Node.js, other managers like yarn and pnpm are widely used and offer different features, performance characteristics, and dependency resolution strategies.

Our monorepo and various other projects may use different package managers. To ensure a developer can work on any project without friction, the development environment should support the tools used by those projects.

Decision

The 07_nodejs Ansible role will install and configure multiple package managers.

Specifically, in addition to npm (which is installed by default with Node.js), the role will also install yarn. The monorepo itself uses pnpm, which is installed as a dev dependency via npm and managed by corepack.

This ensures that the three most common package managers in our ecosystem (npm, yarn, pnpm) are available on all development machines, providing a flexible environment that can accommodate the tooling choices of any given project.

Consequences

Positive:

  • Flexibility: Developers can immediately work on any project, regardless of which package manager it uses, without needing to manually install and configure tools. This reduces setup friction.
  • Consistency: Ensures that all developers have the same set of core package management tools available, leading to a more consistent development environment across the team.
  • Accommodates Project Diversity: Acknowledges that there is no one-size-fits-all solution for package management and allows different projects to choose the tool that is best for them.

Negative:

  • Minor Bloat: Installing multiple package managers adds a small amount of "bloat" to the system, as we are installing tools that may not be used by every single developer.
  • Potential for Confusion: Inexperienced developers might be confused about which package manager to use for a given task.

Mitigation:

  • Negligible Cost: The disk space and installation time for these tools are negligible. The flexibility gained is well worth this minor cost.
  • Project-Level Convention: The choice of which package manager to use is not left up to individual developer preference; it is a project-level decision, typically enforced by the presence of a specific lock file (package-lock.json, yarn.lock, pnpm-lock.yaml) in the project's repository. Developers are expected to use the package manager that the project has chosen. Clear instructions in project READMEs further mitigate this confusion.