Skip to content

[BUG] npx binary does not account for globally-installed packages #1746

@billyjanitsch

Description

@billyjanitsch

Current Behavior:

If a package foo that exposes a binary is installed globally, npm 7's npx foo does not work as expected. It asks whether to install foo rather than executing the already-installed binary.

This issue also occurs if the binary does not share the package name (e.g. if foo exposes binary bar, then npx bar doesn't work either).

Expected Behavior:

npx foo should invoke a globally-installed foo, as in npm@6. Or, if this change is intentional, could it be mentioned alongside the other breaking changes to npx in the npm@7 release notes?

Steps To Reproduce:

  1. Run npm install -g npm-check-updates.
  2. Run ncu. It successfully runs the npm-check-updates binary, as expected.
  3. Run npx ncu. It does not run the binary. Instead, it asks whether it can install the ncu package:
Need to install the following packages:
  ncu
Ok to proceed? (y)

Environment:

  • OS: macOS 10.15.6
  • node: 14.9.0
  • npm: 7.0.0-beta.7

Metadata

Metadata

Assignees

Labels

Bugthing that needs fixingRelease 7.xwork is associated with a specific npm 7 release

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions