GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(arborist): do not install inert optional extraneous shared dependencies by lovell · Pull Request #9221 · npm/cli

Conversation

@lovell

@lovell lovell commented Apr 13, 2026

Copy link
Copy Markdown
Contributor

A shared dependency of two or more umet optional dependencies, where no other package in the tree also depends on that shared package, does not need to be installed.

This removes packages currently marked as extraneous from trees where one or more failed-optional (platform-specific) packages share a transitive dependency, with @emnapi/runtime being a good example of this.

Before:

$ node /path/to/cli/bin/npm-cli.js install [email protected]
added 9 packages in 325ms

$ npm ls --all
├─┬ @emnapi/[email protected] extraneous
│ └── [email protected] deduped
├─┬ @img/[email protected] extraneous
│ └── @emnapi/[email protected] deduped
├─┬ [email protected]
│ ├── @img/[email protected]
│ ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
│ ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
│ ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
│ ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
│ ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
│ ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
│ ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
│ ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
│ ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
│ ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
│ ├── @img/[email protected]
│ ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
│ ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
│ ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
│ ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
│ ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
│ ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
│ ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
│ ├─┬ @img/[email protected]
│ │ └── @img/[email protected] deduped
│ ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
│ ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
│ ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
│ ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
│ ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
│ ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
│ ├── [email protected]
│ └── [email protected]
└── [email protected] extraneous

$ du -s node_modules/
28824	node_modules/

After:

$ node /path/to/cli/bin/npm-cli.js install [email protected]
added 6 packages in 1s

$ npm ls --all
└─┬ [email protected]
  ├── @img/[email protected]
  ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
  ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
  ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
  ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
  ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
  ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
  ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
  ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
  ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
  ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
  ├── @img/[email protected]
  ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
  ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
  ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
  ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
  ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
  ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
  ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
  ├─┬ @img/[email protected]
  │ └── @img/[email protected] deduped
  ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
  ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
  ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
  ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
  ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
  ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
  ├── [email protected]
  └── [email protected]

$ du -s node_modules/
18336	node_modules/

References

Fixes #8832

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

styfle reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@lovell
fix(arborist): remove inert optional extraneous shared deps
6dae62e
A shared dependency of two or more umet optional dependencies,
where no other package in the tree also depends on that shared
package, does not need to be installed.

This removes packages currently marked as extraneous from trees
where some platform-specific packages share a dependency.
@lovell
lovell requested a review from a team as a code owner April 13, 2026 07:45
@lovell lovell mentioned this pull request Apr 13, 2026
[BUG] npm ls command listing EXTRANEOUS package for clean install #8832
Closed
2 tasks done
@wraithgar

wraithgar commented Apr 14, 2026

Copy link
Copy Markdown
Contributor

The big "breaking change" to make sure we are aware of here is that the package lock is not altered in these cases. The package-lock still needs these listed, even if they are not reified.

I don't think this introduces that breaking change but it is something we want to check for.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@lovell

lovell commented Apr 14, 2026

Copy link
Copy Markdown
Contributor Author

Thank you for looking at this Gar.

The package-lock still needs these listed, even if they are not reified.

The lockfiles generated when installing [email protected] in an empty directory appear to be identical before and after the change in this PR.

$ sha256sum package-lock.json.*
36ec3b310f608214cf23aeecbec71f58d0cac4720b2fe4650aa1f8acca000b85  package-lock.json.after
36ec3b310f608214cf23aeecbec71f58d0cac4720b2fe4650aa1f8acca000b85  package-lock.json.before
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@wraithgar wraithgar closed this Apr 14, 2026
@wraithgar wraithgar reopened this Apr 14, 2026
@wraithgar wraithgar added the backport:v11 label Apr 14, 2026
@wraithgar wraithgar mentioned this pull request Apr 15, 2026
fix(arborist): fix infinite loop with bundledDependencies and overrides #9235
Merged
wraithgar
wraithgar approved these changes Apr 15, 2026
View reviewed changes
@wraithgar
wraithgar merged commit 1d058b0 into npm:latest Apr 15, 2026
44 of 48 checks passed

Uh oh!

There was an error while loading. Please reload this page.

github-actions Bot pushed a commit that referenced this pull request Apr 15, 2026
@lovell @npm-cli-bot
fix(arborist): do not install inert optional extraneous shared depend…
b908353
…encies (#9221)

A shared dependency of two or more umet optional dependencies, where no
other package in the tree also depends on that shared package, does not
need to be installed.

This removes packages currently marked as extraneous from trees where
one or more failed-optional (platform-specific) packages share a
transitive dependency, with `@emnapi/runtime` being a good example of
this.

Before:
```
$ node /path/to/cli/bin/npm-cli.js install [email protected]
added 9 packages in 325ms

$ npm ls --all
├─┬ @emnapi/[email protected] extraneous
│ └── [email protected] deduped
├─┬ @img/[email protected] extraneous
│ └── @emnapi/[email protected] deduped
├─┬ [email protected]
│ ├── @img/[email protected]
│ ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
│ ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
│ ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
│ ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
│ ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
│ ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
│ ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
│ ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
│ ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
│ ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
│ ├── @img/[email protected]
│ ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
│ ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
│ ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
│ ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
│ ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
│ ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
│ ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
│ ├─┬ @img/[email protected]
│ │ └── @img/[email protected] deduped
│ ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
│ ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
│ ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
│ ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
│ ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
│ ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
│ ├── [email protected]
│ └── [email protected]
└── [email protected] extraneous

$ du -s node_modules/
28824	node_modules/
```

After:
```
$ node /path/to/cli/bin/npm-cli.js install [email protected]
added 6 packages in 1s

$ npm ls --all
└─┬ [email protected]
  ├── @img/[email protected]
  ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
  ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
  ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
  ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
  ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
  ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
  ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
  ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
  ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
  ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
  ├── @img/[email protected]
  ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
  ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
  ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
  ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
  ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
  ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
  ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
  ├─┬ @img/[email protected]
  │ └── @img/[email protected] deduped
  ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
  ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
  ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
  ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
  ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
  ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
  ├── [email protected]
  └── [email protected]

$ du -s node_modules/
18336	node_modules/
```

## References

Fixes #8832

(cherry picked from commit 1d058b0)
@github-actions

github-actions Bot commented Apr 15, 2026

Copy link
Copy Markdown
Contributor

⚠️ Backport to release/v11 failed.

This usually means the cherry-pick had conflicts. Please create a manual backport:

git fetch origin release/v11
git checkout -b backport/v11/9221 origin/release/v11
git cherry-pick -x 1d058b0cc7161fa728cba2020a265a81e0ec7cdf
# resolve any conflicts, then:
git push origin backport/v11/9221
Error details
Resource not accessible by integration
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This was referenced Apr 15, 2026
fix(arborist): do not install inert optional extraneous shared dependencies #9238
Merged
chore: release 12.0.0-pre.0.0 #9229
Merged
wraithgar pushed a commit that referenced this pull request Apr 15, 2026
@github-actions @lovell
fix(arborist): do not install inert optional extraneous shared depend…
7e3a66e
…encies (#9238)

Backport of #9221 to `release/v11`.

Co-authored-by: Lovell Fuller <[email protected]>
@lovell
lovell deleted the arborist-optional-set-remove-shared-extraneous branch April 16, 2026 10:27
reggi pushed a commit that referenced this pull request Apr 21, 2026
@lovell @reggi
fix(arborist): do not install inert optional extraneous shared depend…
555e01b
…encies (#9221)

A shared dependency of two or more umet optional dependencies, where no
other package in the tree also depends on that shared package, does not
need to be installed.

This removes packages currently marked as extraneous from trees where
one or more failed-optional (platform-specific) packages share a
transitive dependency, with `@emnapi/runtime` being a good example of
this.

Before:
```
$ node /path/to/cli/bin/npm-cli.js install [email protected]
added 9 packages in 325ms

$ npm ls --all
├─┬ @emnapi/[email protected] extraneous
│ └── [email protected] deduped
├─┬ @img/[email protected] extraneous
│ └── @emnapi/[email protected] deduped
├─┬ [email protected]
│ ├── @img/[email protected]
│ ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
│ ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
│ ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
│ ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
│ ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
│ ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
│ ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
│ ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
│ ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
│ ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
│ ├── @img/[email protected]
│ ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
│ ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
│ ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
│ ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
│ ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
│ ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
│ ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
│ ├─┬ @img/[email protected]
│ │ └── @img/[email protected] deduped
│ ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
│ ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
│ ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
│ ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
│ ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
│ ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
│ ├── [email protected]
│ └── [email protected]
└── [email protected] extraneous

$ du -s node_modules/
28824	node_modules/
```

After:
```
$ node /path/to/cli/bin/npm-cli.js install [email protected]
added 6 packages in 1s

$ npm ls --all
└─┬ [email protected]
  ├── @img/[email protected]
  ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
  ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
  ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
  ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
  ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
  ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
  ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
  ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
  ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
  ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
  ├── @img/[email protected]
  ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
  ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
  ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
  ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
  ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
  ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
  ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
  ├─┬ @img/[email protected]
  │ └── @img/[email protected] deduped
  ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
  ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
  ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
  ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
  ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
  ├── UNMET OPTIONAL DEPENDENCY @img/[email protected]
  ├── [email protected]
  └── [email protected]

$ du -s node_modules/
18336	node_modules/
```

## References

Fixes #8832
@github-actions github-actions Bot mentioned this pull request May 27, 2026
chore: release 12.0.0-pre.1 #9387
Merged
@lovell lovell mentioned this pull request Jun 12, 2026
chore: upgrade [email protected] styfle/packagephobia#1098
Merged
styfle added a commit to styfle/packagephobia that referenced this pull request Jun 12, 2026
@lovell @styfle
chore: upgrade [email protected] (#1098)
135741c
Versions of npm between 11.6.2 and 11.12.1 inclusive contained a bug
that resulted in inert optional extraneous shared dependencies being
installed where they were not required.

npm/cli#9221

It looks like the Packagephobia-reported installation size of [sharp
0.35.0](https://packagephobia.com/result?p=sharp%400.35.0) was affected
by this.

---------

Co-authored-by: Steven <[email protected]>
@devrodri-com devrodri-com mentioned this pull request Aug 13, 2026
Security 03: update Next.js to 16.3.1 devrodri-com/magenta-paysandu#30
Merged
@marcoshernanz marcoshernanz mentioned this pull request Aug 25, 2026
extraneous emnapi/[email protected] in Next.js 15 via Sharp cannot remove vercel/next.js#84450
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

1 more reviewer
@wraithgar wraithgar wraithgar approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

backport:v11

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

[BUG] npm ls command listing EXTRANEOUS package for clean install

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@lovell @wraithgar
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.