Skip to content

Conversation

@MaxBlack-dev
Copy link
Contributor

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:

Testing:

  • All existing tests pass
  • The fix is minimal and non-breaking: it simply skips the binDir expansion when no filesystem path is available

…path

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.

Affects users with custom/private registries that don't pre-calculate
the 'bin' field from 'directories.bin' in their package manifests.
@MaxBlack-dev MaxBlack-dev requested a review from a team as a code owner November 14, 2025 22:03
@wraithgar
Copy link
Member

This will need a test

@MaxBlack-dev
Copy link
Contributor Author

This will need a test

Test is added, please take a look.

@owlstronaut owlstronaut self-assigned this Nov 17, 2025
Copy link
Contributor

@owlstronaut owlstronaut left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pragmatic, thank you for the contribution

@owlstronaut owlstronaut merged commit 57952b8 into npm:main Nov 18, 2025
17 checks passed
@github-actions github-actions bot mentioned this pull request Nov 18, 2025
owlstronaut pushed a commit that referenced this pull request Nov 18, 2025
🤖 I have created a release *beep* *boop*
---


## [7.0.3](v7.0.2...v7.0.3)
(2025-11-18)
### Bug Fixes
*
[`57952b8`](57952b8)
[#164](#164) prevent crash when
expanding directories.bin without filesystem path (#164) (@MaxBlack-dev,
Max Black)
### Dependencies
*
[`ba5c736`](ba5c736)
[#165](#165) bump glob from
11.1.0 to 12.0.0 (#165) (@dependabot[bot])

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] npm commands can fail with ERR_INVALID_ARG_TYPE when normalizing manifests including a directories.bin field

4 participants