Skip to content

[BUG] install-strategy=linked: .store and stale directories not cleaned up when switching install strategy #9615

Closed

Description

@manzoorwanijk

Part of #9608.

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • I am using the latest npm

This is not just a request to bump a dependency for a CVE

  • This is not solely a request to bump a dependency for a CVE

Current Behavior

Switching the install strategy in the same project directory leaves stale state in both directions. Switching hoisted → linked leaves the previous strategy's real top-level transitive directories (e.g. balanced-match, brace-expansion, concat-map) on disk alongside the new .store/ and symlinks. Switching linked → hoisted leaves the entire node_modules/.store/ directory behind. A fresh install of either strategy produces a clean layout.

Expected Behavior

Switching strategy should remove the layout artifacts of the previous strategy: stale top-level real directories should be cleaned up when entering the linked strategy, and .store/ should be removed when leaving it.

Steps To Reproduce

cd "$(mktemp -d)"
echo '{ "name": "sw", "version": "1.0.0", "dependencies": { "minimatch": "3.0.4" } }' > package.json

echo 'install-strategy=hoisted' > .npmrc
npm install >/dev/null            # real dirs: balanced-match, brace-expansion, concat-map, minimatch
echo 'install-strategy=linked' > .npmrc
npm install >/dev/null
ls -l node_modules | grep -E 'balanced-match|brace-expansion|concat-map'  # still real dirs (stale)
# a fresh linked install has only `minimatch` (symlink) + .store/

# reverse direction:
echo 'install-strategy=hoisted' > .npmrc
npm install >/dev/null
ls node_modules/.store            # still present (stale); a fresh hoisted install has no .store

Environment

  • npm: 12.0.0-pre.1 (latest)
  • Node.js: v24.17.0
  • OS Name: macOS (Darwin 25.5.0)
  • System Model Name: MacBook (arm64)
  • npm config:
install-strategy=linked

Activity

  1. added a commit that references this issue on Jun 24, 2026
    ca92323
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions