Skip to content

fix(arborist): omit linked packages' dev deps from npm audit --omit - #10196

Open
ljharb wants to merge 1 commit into
npm:latestfrom
ljharb:fix/audit-omit-linked-dev-deps
Open

ljharb wants to merge 1 commit into
npm:latestfrom
ljharb:fix/audit-omit-linked-dev-deps

Conversation

@ljharb

@ljharb ljharb commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

AuditReport#shouldAudit used Node#shouldOmit, which never omits a node whose top is not the project root or a workspace. A linked package's target is its own top, so its devDependencies were always audited even though their dep flags are correctly propagated through the link.

Audit now checks the dep flags directly via a new Node#hasOmittedDepType. shouldOmit is unchanged, so reify still never removes anything from a linked package's own node_modules. Deps of an undeclared link target (whose flags were never calculated) are still always audited.

Fixes #9624

`AuditReport#shouldAudit` used `Node#shouldOmit`,
which never omits a node whose `top` is not the project root or a workspace.
A linked package's target is its own `top`,
so its devDependencies were always audited even though their dep flags are correctly propagated through the link.

Audit now checks the dep flags directly via a new `Node#hasOmittedDepType`.
`shouldOmit` is unchanged,
so reify still never removes anything from a linked package's own `node_modules`.
Deps of an undeclared link target
(whose flags were never calculated) are still always audited.

Fixes npm#9624
@ljharb
ljharb requested a review from a team as a code owner October 30, 2026 23:57
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.

[BUG] npm audit --production reports linked packages' dev deps

1 participant