Skip to content

[BUG] npm exec does not use globally installed scoped packages #4054

Description

@dominykas

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

If you npm -g a scoped package, running npx against it will ask if you want to install it (or fail with --no).

Expected Behavior

npx should use globally installed scoped packages.

Steps To Reproduce

Does not work when installed globally:

✔ ~/devel/experiments/npx-global 
16:29 $ npm i -g @commitlint/cli

added 171 packages, and audited 172 packages in 13s

23 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
✔ ~/devel/experiments/npx-global 
16:30 $ npx --no @commitlint/cli
npm ERR! canceled

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/dominykas/.npm/_logs/2021-11-17T14_30_15_850Z-debug.log

Works when installed locally:

✘-1 ~/devel/experiments/npx-global 
16:30 $ npm i @commitlint/cli

added 171 packages, and audited 172 packages in 2s

23 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
✔ ~/devel/experiments/npx-global [0] 
16:30 $ npx --no @commitlint/cli
@commitlint/[email protected] - Lint your commit messages

Works when using an unscoped package:

✔ ~/devel/experiments/npx-global [0] 
16:35 $ npm i -g eslint

added 88 packages, and audited 89 packages in 3s

13 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
✔ ~/devel/experiments/npx-global [0] 
16:35 $ npx --no -- eslint -v
v8.2.0

Environment

  • npm: v8.1.3
  • Node: v16.3.0
  • OS: macos
  • platform:
  • npm config:
; copy and paste output from `npm config ls` here

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Bugthing that needs fixingPriority 2secondary priority issueRelease 8.xwork is associated with a specific npm 8 releasecmd:execrelated to `npx`

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions