Commit 57952b8
fix: prevent crash when expanding directories.bin without filesystem path (#164)
Fixes npm/cli#8722
When normalizing a package manifest fetched from a registry (without a
filesystem path), attempting to expand 'directories.bin' would crash
with ERR_INVALID_ARG_TYPE because pkg.path is undefined.
This adds a check to only expand directories.bin when pkg.path exists,
preventing the crash while maintaining correct behavior for packages
with a filesystem location.
**Impact:**
- Affects users with custom/private registries (GitLab, Artifactory,
etc.) that don't pre-calculate the 'bin' field
- The npm public registry pre-calculates this field, which is why the
issue isn't visible there
- Multiple users have reported this issue in npm/cli#8722
**Testing:**
- All existing tests pass
- The fix is minimal and non-breaking: it simply skips the binDir
expansion when no filesystem path is available
---------
Co-authored-by: Max Black <[email protected]>1 parent ba5c736 commit 57952b8
2 files changed
Lines changed: 15 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
474 | 474 | | |
475 | 475 | | |
476 | 476 | | |
477 | | - | |
| 477 | + | |
478 | 478 | | |
479 | 479 | | |
480 | 480 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
172 | 172 | | |
173 | 173 | | |
174 | 174 | | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
175 | 189 | | |
176 | 190 | | |
177 | 191 | | |
| |||
0 commit comments