You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 4c9eacb
Browse filesBrowse the repository at this point in the historyBrowse files
// The .store directory is exclusively a linked-strategy artifact, and load-actual ignores dot-directories, so the diff never sees it.
149
+
// Remove it here when switching away from linked so it does not linger under hoisted/nested.
150
+
// Only do this for a full-project install: a workspace-filtered or --workspaces=false install may leave out-of-scope workspaces with links still pointing into the store.
log.silly('reify','removing stale .store from a previous linked install')
1456
+
awaitrm(storeDir,{recursive: true,force: true})
1457
+
.catch(/* istanbul ignore next -- rm with force rarely fails */
1458
+
er=>log.warn('cleanup','Failed to remove stale .store directory',er))
1459
+
}
1460
+
1441
1461
// After a linked install, scan node_modules/.store/ and remove any directories that are not referenced by the current ideal tree.
1442
1462
// Store entries become orphaned when dependencies are updated or removed, because the diff never sees the old store keys.
1443
1463
// Then sweep the top-level node_modules/ for orphaned symlinks (e.g. an uninstalled dep whose store entry was just removed) so we don't leave dangling links.
// Locations are normalized to forward slashes here because IsolatedNode/IsolatedLink locations are built with path.join, which uses backslashes on Windows.
1477
1497
constvalidKeys=newSet()
1478
1498
constnmDirs=newMap()
1479
-
// Valid bin shim names per node_modules dir, collected from each top-level link's package.bin so the .bin sweep keeps only shims a still-linked package provides.
1499
+
// Valid bin shim names per node_modules dir, collected from each top-level entry's package.bin so the .bin sweep keeps only shims a still-installed package provides.
// Remove node_modules/ entries that aren't represented in the ideal tree.
1641
1659
// Run for the project root and each workspace's node_modules.
1642
1660
// The linked diff path can't see these because #buildLinkedActualForDiff derives the actual tree from the ideal, so removed deps are never compared.
1643
-
// Only symlinks whose target resolves inside the project root are removed — that covers store links (node_modules/.store/...) and workspace self-links (e.g. node_modules/<ws> -> ../packages/<ws>) that npm itself created.
1644
-
// Symlinks pointing outside the project (e.g. `npm link foo` without --save targeting the global prefix, or hand-made `ln -s` to an external path) and real directories are preserved.
1661
+
// Two kinds of stale entry are removed:
1662
+
// - symlinks whose target resolves inside the project root — store links (node_modules/.store/...) and workspace self-links (e.g. node_modules/<ws> -> ../packages/<ws>) that npm itself created.
1663
+
// - real package directories — hoisted-layout deps left behind when switching from the hoisted strategy to linked, where every valid top-level entry is a symlink.
1664
+
// Symlinks pointing outside the project (e.g. `npm link foo` without --save targeting the global prefix, or hand-made `ln -s` to an external path) and non-package real directories are preserved.
0 commit comments