[BUG] npx/exec unable to run bin scripts with . in name on Windows
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 10.1k
- Forks
- 4.7k
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 19
Description
Is there an existing issue for this?
- I have searched the existing issues[^1]
[^1]: There was a previous issue opened for the same problem (https://github.com/npm/cli/issues/4445) but that was closed in favor of an issue on the npm/exec repo (https://github.com/npm/exec/issues/17). However, that issue was automatically closed when that repo was archived, so I am creating this new issue to make sure that this is still tracked as an open bug.
This issue exists in the latest npm version
- I am using the latest npm
Current Behavior
For a package with a bin script that contains the character . in the name[^2] it cannot be executed with npx/npm exec from a Windows machine. Rather than executing the script, Windows attempts to open the file and search for a application based on the extension.
[^2]: Please note that this also extends to packages that contain . in their name, if they have a single bin script. For example, a package @org/namespace.foo with "bin": "script.js" would be impossible to run with npx @org/namespace.foo.
This is not an issue on other operating systems.
Expected Behavior
The npx/npm exec behavior for bin scripts should be the same for all operating systems. You should be able to call any of the bin scripts in a package.
Steps To Reproduce
Reproduction contained in this repo: https://github.com/molisani/npm-windows-bin-issue
- Update package with a bin script with
.in the name - Attempt to run
npm exec --package=<package> <bin-name>from Windows - See that it attempts to open
<bin-name>as a file
Environment
- npm: 11.5.2
- Node.js: 22.14.0
- OS Name: Windows 10 Enterprise
- System Model Name: Thinkpad X1 Extreme Gen 4
- npm config:
; "builtin" config from C:\Users\mmolisani\AppData\Roaming\npm\node_modules\npm\npmrc
; prefix = "C:\\Users\\mmolisani\\AppData\\Roaming\\npm" ; overridden by user
; "user" config from C:\Users\mmolisani\.npmrc
audit = false
engine-strict = true
prefix = "C:\\Users\\mmolisani\\AppData\\Roaming\\npm"
; registry = [[REDACTED]] ; overridden by env
strict-ssl = false
; "env" config from environment
registry = [[REDACTED]]
; node bin location = C:\Program Files\nodejs\node.exe
; node version = v22.14.0
; npm local prefix = C:\code\github\npm-windows-bin-issue
; npm version = 11.5.2
; cwd = C:\code\github\npm-windows-bin-issue
; HOME = C:\Users\mmolisani
; Run `npm config ls -l` to show all defaults.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked reproduction repository and run its steps on Windows using npm exec or npx. Trace the npm exec entry point involved in selecting and launching a bin name containing a period, then verify that the same command executes the bin rather than opening it as a file on Windows.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nodejs
- Domain
- cli, devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100