Support npm `install-strategy=linked` (`.store` directory layout)
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 52/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- nodejs, typescript
- Domain
- tooling
Research direction
Start by locating patch-package's package lookup and patch-application entry points; the issue does not name repository files or tests. Reproduce with npm install-strategy=linked and inspect the expected node_modules path, its symlink, and node_modules/.store layout. Done means nested and workspace patches apply successfully from the linked layout.
Written by the indexing model from the issue text.
Description
Bug report
When npm is configured with install-strategy=linked (an experimental feature in npm), packages are stored in node_modules/.store/<pkg>@<version>-<hash>/node_modules/<pkg>/ and symlinked into consuming packages' node_modules/. patch-package cannot find packages at these paths and fails to apply patches.
Current Behavior
With install-strategy=linked in .npmrc, running patch-package in postinstall fails with:
Error: Patch file found for package lighthouse which is not present at node_modules/@wordpress/e2e-test-utils-playwright/node_modules/lighthouse
The package exists, but at a different path:
node_modules/.store/lighthouse@12.2.2-E1oDY3hhcKvr16czLc4uyw/node_modules/lighthouse/
A symlink exists at the expected nested path, but it points into .store/:
packages/e2e-test-utils-playwright/node_modules/lighthouse ->
../../../node_modules/.store/lighthouse@12.2.2-E1oDY3hhcKvr16czLc4uyw/node_modules/lighthouse
This affects both nested patches (parent++child+version.patch) and, in monorepo/workspace setups, any packages whose dependencies are stored exclusively in .store/.
Expected behavior
patch-package should resolve the actual package location by following symlinks or by searching the .store/ directory when the traditional node_modules/ path doesn't contain the package directly.
Possible Solution
When looking up a package to patch, if the expected node_modules/<pkg> path is a symlink, follow it to find the real package directory and apply the patch there. Alternatively, add support for searching node_modules/.store/ for <pkg>@<version>-* entries.
This is related to #277 (monorepo hoisting) in that both involve packages not being at the path patch-package expects, but the root cause here is the npm linked install strategy's .store/ layout rather than workspace hoisting.
Context
npm's install-strategy=linked is an experimental feature that deduplicates packages by storing them in a content-addressed .store/ directory and creating symlinks. As this strategy matures and sees wider adoption, patch-package will need to handle this layout.
Our workaround is a custom apply-patches.mjs script that:
- Parses patch filenames to extract package name and version
- Looks up the package in
node_modules/.store/<pkg>@<version>-*/node_modules/<pkg>/ - Rewrites diff paths in the patch to target the actual
.store/location - Applies patches using
git apply --ignore-whitespace
Your Environment
| Software | Version(s) |
|---|---|
| patch-package | 8.0.0 |
| npm | 10.9.5 |
| node | 20.x+ |
- Dominant language
- TypeScript
- Stars
- 11.2k
- Forks
- 325
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ds300/patch-package
-
Difficulty 1/5 Under an hour Newbie friendliness 82/100
ds300/patch-package#617 · 1 reaction ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
ds300/patch-package#615 · 3 reactions ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
ds300/patch-package#216 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 25/100
ds300/patch-package#611 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
ds300/patch-package#610 · 2 comments · 1 reaction ·
All issues in ds300/patch-package
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
copse-dev/agent-pane#2953 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
bug clawsweeper:linked-pr-open clawsweeper:needs-live-repro clawsweeper:no-new-fix-pr impact:message-loss issue-rating: 🐚 platinum hermit P2 regression
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·