Skip to content

fix(install): remove stale root node_modules symlink on deno remove#35137

Merged
bartlomieju merged 1 commit into
mainfrom
fix/remove-stale-root-node-modules-symlink
Jun 13, 2026
Merged

fix(install): remove stale root node_modules symlink on deno remove#35137
bartlomieju merged 1 commit into
mainfrom
fix/remove-stale-root-node-modules-symlink

Conversation

@bartlomieju

Copy link
Copy Markdown
Member

In the pnpm-style local node_modules layout, only direct dependencies get a
symlink at the root of node_modules. However, when a direct dependency was
removed but remained in the resolution as a transitive dependency of another
package, "deno remove" left its root symlink behind, leaking it as a phantom
dependency. A fresh "deno install" after deleting node_modules correctly did
not link it at the root, confirming the leftover entry was a stale artifact.

This happened for two reasons: the cleanup pass kept any root symlink whose
target package was still anywhere in the resolution (instead of only packages
expected at the root), and the change-detection hash only covered package ids,
so removing an import that survived as a transitive dependency did not change
the hash and the cleanup never ran. The cleanup now keeps only the packages
expected at the root (resolved package.json and import map dependencies plus
the snapshot's top level packages) and the hash includes that set, matching
what pnpm does.

Fixes #35083

@bartlomieju
bartlomieju merged commit 50c49c8 into main Jun 13, 2026
136 checks passed
@bartlomieju
bartlomieju deleted the fix/remove-stale-root-node-modules-symlink branch June 13, 2026 08:08
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.

Packages persist in node_modules after deno remove

1 participant