mirror of
https://github.com/pnpm/pnpm.git
synced 2026-07-25 23:17:08 -04:00
fix: directories are not being removed from node_modules while linking commands (#7101)
close #6756
This commit is contained in:
6
.changeset/wild-jeans-carry.md
Normal file
6
.changeset/wild-jeans-carry.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"@pnpm/headless": patch
|
||||
"pnpm": patch
|
||||
---
|
||||
|
||||
Fixed an ENOENT error that was sometimes happening during install with "hoisted" `node_modules` [#6756](https://github.com/pnpm/pnpm/issues/6756).
|
||||
@@ -46,9 +46,11 @@ export async function linkHoistedModules (
|
||||
prefix: opts.lockfileDir,
|
||||
removed: dirsToRemove.length,
|
||||
})
|
||||
await Promise.all([
|
||||
...dirsToRemove.map((dir) => tryRemoveDir(dir)),
|
||||
...Object.entries(hierarchy)
|
||||
// We should avoid removing unnecessary directories while simultaneously adding new ones.
|
||||
// Doing so can sometimes lead to a race condition when linking commands to `node_modules/.bin`.
|
||||
await Promise.all(dirsToRemove.map((dir) => tryRemoveDir(dir)))
|
||||
await Promise.all(
|
||||
Object.entries(hierarchy)
|
||||
.map(([parentDir, depsHierarchy]) => {
|
||||
function warn (message: string) {
|
||||
logger.info({
|
||||
@@ -60,8 +62,8 @@ export async function linkHoistedModules (
|
||||
...opts,
|
||||
warn,
|
||||
})
|
||||
}),
|
||||
])
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
async function tryRemoveDir (dir: string) {
|
||||
|
||||
Reference in New Issue
Block a user