fix: no permission to delete empty directories (#7406)

close #7405
This commit is contained in:
Xc
2023-12-13 16:54:40 +08:00
committed by GitHub
parent d5a176af77
commit f3cd0a61d4
2 changed files with 12 additions and 1 deletions

View File

@@ -0,0 +1,6 @@
---
"@pnpm/modules-cleaner": patch
"pnpm": patch
---
Installation should not fail if an empty `node_modules` directory cannot be removed [#7405](https://github.com/pnpm/pnpm/issues/7405).

View File

@@ -114,7 +114,12 @@ export async function prune (
})
}))
await Promise.all(Array.from(removedFromScopes).map((scope) => removeIfEmpty(path.join(modulesDir, scope))))
await removeIfEmpty(modulesDir)
try {
await removeIfEmpty(modulesDir)
} catch {
// On some server setups we might not have permission to remove the node_modules directory.
// That's fine, just proceed.
}
}))
const selectedImporterIds = importers.map((importer) => importer.id).sort()