Skip to content

RFC: Opt out of auto-installing peer dependencies - #926

Open
manzoorwanijk wants to merge 1 commit into
npm:mainfrom
manzoorwanijk:rfc-auto-install-peers-opt-out
Open

manzoorwanijk wants to merge 1 commit into
npm:mainfrom
manzoorwanijk:rfc-auto-install-peers-opt-out

Conversation

@manzoorwanijk

@manzoorwanijk manzoorwanijk commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds an RFC for an auto-install-peers config that lets a project stop npm from auto-installing required peers and report any package that forgets to declare a peer it consumes. A package author who depends on B (peer react) but never declares react gets no signal today, because npm installs it on B's behalf. The mistake then ships, and consumers on Yarn Plug'n'Play hit it at runtime.

Notable semantics

  • Default stays true, so nothing changes unless opted in.
  • Checks manifest declarations, not placement, so hoisted and linked give the same result.
  • Warns by default; under strict-peer-deps, root and workspace violations fail, third-party ones warn.
  • Covers peer chains, workspaces and third-party dependents; optional peers and bundled deps are exempt.
  • Stale auto-installed peers in a lockfile are pruned, and npm ci fails as out of sync.
  • No effect under legacy-peer-deps.

Related:


Disclosure: Codex and Claude Code were used to draft the initial version of this RFC and to iterate on it during review.

@manzoorwanijk
manzoorwanijk marked this pull request as ready for review September 29, 2026 10:59
@manzoorwanijk
manzoorwanijk requested a review from a team as a code owner September 29, 2026 10:59
@manzoorwanijk
manzoorwanijk force-pushed the rfc-auto-install-peers-opt-out branch from 151de87 to 3faff9d Compare September 29, 2026 11:09
@manzoorwanijk

manzoorwanijk commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor Author

CC: @reggi @martinrrm @nkolev92

I will create a draft implementation for you to look at.

@manzoorwanijk

Copy link
Copy Markdown
Contributor Author

Here is the draft implementation - npm/cli#10049

@manzoorwanijk
manzoorwanijk force-pushed the rfc-auto-install-peers-opt-out branch from 3faff9d to 6fcd15c Compare October 2, 2026 08:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant