Skip to content

Use one rule for a project's target Node.js across nodeVersion, runtime pins, and the host in pnpm v12 #68

Closed
pnpm/pnpm
#16563

Description

@zkochan

pnpm v12 has no single rule for which Node.js a project's dependencies run on. Each caller combines four sources itself, and the callers use different orders:

  • the nodeVersion setting
  • a devEngines.runtime or engines.runtime pin in the root manifest
  • the root importer's node@runtime: dependency in the lockfile
  • the node on PATH
Decides Order Code
Package compatibility checks for the install nodeVersion, then the runtime pin, then the host with_locked_runtime_node, effective_node_version
Project engines.node check at startup nodeVersion, then the manifest pin, then the host state.rs
Global virtual store directory names and the side-effects cache key the lockfile pin, then the host (with nodeVersion already applied to the host) resolve_engine_name
Store layout for commands that read an installed lockfile the lockfile pin, then the value the caller passes, then the host virtual_store_layout_for_lockfile, called from licenses with nodeVersion or the manifest pin

With nodeVersion: 22 and a runtime pin for Node.js 24, pnpm checks packages against 22 but stores them under a node24 directory name. That split may be intended, because nodeVersion is documented as an override for compatibility checks. Nothing in the code states it as a rule, and each new caller has to pick an order again.

Proposed change

  1. Decide the intended order for compatibility checks and for store directory names. Check what pnpm v11 does when nodeVersion and a runtime pin are both set, and match it.
  2. Add one function in deps-restorer that returns the project's target Node.js for each use, and document the order there.
  3. Switch every caller in the table to it. Add a test with nodeVersion and a runtime pin for different majors, covering both the compatibility check and the store directory name.

pnpm's own install is a separate case: pnpm runs on the node on PATH whatever the project sets. That case is tracked in #67.


Written by an agent (Claude Code, claude-opus-5-5).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions