Skip to content

fix(arborist): ignore hidden entries in global update#9299

Merged
owlstronaut merged 1 commit intonpm:latestfrom
Grynn:fix-global-update-hidden-entries
May 4, 2026
Merged

fix(arborist): ignore hidden entries in global update#9299
owlstronaut merged 1 commit intonpm:latestfrom
Grynn:fix-global-update-hidden-entries

Conversation

@Grynn
Copy link
Copy Markdown
Contributor

@Grynn Grynn commented May 3, 2026

Description

Fixes #9298.

buildIdealTree handles global updates by reading the global node_modules folder directly and adding each entry as a synthetic top-level dependency. That path did not ignore hidden entries, so a directory like .hidden-non-package was converted to .hidden-non-package@* and rejected by npm-package-arg.

This applies the same hidden-entry filter already used by loadActual, so hidden directories and retired scoped package folders are not treated as installed global packages during npm up -g.

Testing

node node_modules/tap/bin/run.js workspaces/arborist/test/arborist/build-ideal-tree.js -g "update global ignores hidden"
npm_config_prefix=/tmp/npm-hidden-global-patched.azXmRd node . up -g
node . run eslint -- workspaces/arborist/lib/arborist/build-ideal-tree.js workspaces/arborist/test/arborist/build-ideal-tree.js

@Grynn Grynn requested a review from a team as a code owner May 3, 2026 06:41
@owlstronaut owlstronaut merged commit 32940e2 into npm:latest May 4, 2026
18 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 4, 2026

🎉 Backport to release/v11 created: #9303

owlstronaut pushed a commit that referenced this pull request May 4, 2026
## Description

Fixes #9298.

`buildIdealTree` handles global updates by reading the global
`node_modules` folder directly and adding each entry as a synthetic
top-level dependency. That path did not ignore hidden entries, so a
directory like `.hidden-non-package` was converted to
`.hidden-non-package@*` and rejected by `npm-package-arg`.

This applies the same hidden-entry filter already used by `loadActual`,
so hidden directories and retired scoped package folders are not treated
as installed global packages during `npm up -g`.

## Testing

```sh
node node_modules/tap/bin/run.js workspaces/arborist/test/arborist/build-ideal-tree.js -g "update global ignores hidden"
```

```sh
npm_config_prefix=/tmp/npm-hidden-global-patched.azXmRd node . up -g
```

```sh
node . run eslint -- workspaces/arborist/lib/arborist/build-ideal-tree.js workspaces/arborist/test/arborist/build-ideal-tree.js
```

(cherry picked from commit 32940e2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

npm up -g fails on hidden directories in global node_modules

2 participants