Skip to content

fix(npm): preserve optional peers in lockfiles - #1798

Merged
John-David Dalton (jdalton) merged 1 commit into
v1.xfrom
fix/1673-preserve-optional-npm-peers
Dec 2, 2026
Merged

John-David Dalton (jdalton) merged 1 commit into
v1.xfrom
fix/1673-preserve-optional-npm-peers

Conversation

@jdalton

@jdalton John-David Dalton (jdalton) commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

The v1.x socket npm wrapper now uses the Arborist that ships with the selected npm. This preserves optional peer entries during lockfile edits and lets npm reject missing entries during ci. Socket wraps only Arborist’s reification entry point and leaves npm’s other tree classes in place. The development pin is updated to Arborist 10.0.5.

Fixes #1673

@cursor

cursor Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

PR Summary

Medium Risk
Touches core shadow-npm resolution and lockfile editing paths; behavior now depends on the located npm installation being loadable via getNpmRequire().

Overview
Socket’s shadow npm now resolves Arborist, Edge, Node, and OverrideSet through getNpmRequire() instead of static @npmcli/arborist imports, so dependency tree and lockfile behavior match the npm version the user actually runs.

installSafeArborist() only registers the SafeArborist patch in require.cache; it no longer overrides the tree helper modules. A Vitest case asserts those exports are identical to the classes shipped inside the selected npm.

Reviewed by Cursor Bugbot for commit 7048197. Configure here.

@jdalton John-David Dalton (jdalton) changed the title Preserve optional npm peers when updating lockfiles fix(npm): preserve optional peers in lockfiles Dec 2, 2026
@jdalton
John-David Dalton (jdalton) force-pushed the fix/1673-preserve-optional-npm-peers branch from 7048197 to 1fcc444 Compare December 2, 2026 01:03
@socket-security

socket-security Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updated@​types/​npmcli__arborist@​6.3.1 ⏵ 6.3.398 +110074 +181100
Updated@​npmcli/​arborist@​9.1.4 ⏵ 10.0.585 -12100100 +197100

View full report

@socket-security-staging

socket-security-staging Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updated@​types/​npmcli__arborist@​6.3.1 ⏵ 6.3.398 +110074 +181100
Updated@​npmcli/​arborist@​9.1.4 ⏵ 10.0.597 -1100100 +194 -3100

View full report

Assisted-by: Codex:GPT-6-Luna
@jdalton
John-David Dalton (jdalton) force-pushed the fix/1673-preserve-optional-npm-peers branch from 1fcc444 to ebe3712 Compare December 2, 2026 01:22
@jdalton
John-David Dalton (jdalton) merged commit 8104d9f into v1.x Dec 2, 2026
23 checks passed
@jdalton
John-David Dalton (jdalton) deleted the fix/1673-preserve-optional-npm-peers branch December 2, 2026 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

socket npm install/uninstall removes optional peer entries from package-lock.json

2 participants