fix: guard Npm.which() against infinite loop when .bin is empty (#16961)

This commit is contained in:
Luke Parker 2026-03-11 23:34:58 +10:00 committed by GitHub
commit 7910ce5d36
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -151,7 +151,9 @@ export namespace Npm {
const files = await readdir(dir).catch(() => [])
if (!files.length) {
await add(pkg)
return which(pkg)
const retry = await readdir(dir).catch(() => [])
if (!retry.length) throw new Error(`No binary found for package "${pkg}" after install`)
return path.join(dir, retry[0])
}
return path.join(dir, files[0])
}