[BUG] *.CMD shims don't work when they are in paths containing shell metachars
@ashrafiucse is already working on this.
Since Sep 12, 2026.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 68/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- javascript
- Domain
- cli
Research direction
Start by locating the code that generates the *.CMD shims and reproduce the reported Windows case with an npm prefix or package path containing '&'. Verify the generated command runs successfully for packages with a bin entry, including both global installation and local npm-run scenarios.
Written by the indexing model from the issue text.
Description
What / Why
Generated
*.CMDfiles are unable to start correctly when the path to theCMDfile contains certain characters.
When
- Whenever the path contains a cmd.exe shell metacharacter (such as
&).
Where
- Any package with a "bin" entry.
How
Current Behavior
- The shell metacharacters are parsed by the shell instead of the full argument being passed into node. With my npm prefix set to "C:/test(n&pm)" and after installing the mkdirp package globally, I see the following error when attempting to run "mkdirp" in cmd.exe.
'pm)\' is not recognized as an internal or external command,
operable program or batch file.
internal/modules/cjs/loader.js:969
throw err;
^
Error: Cannot find module 'C:\test(n\node_modules\mkdirp\bin\cmd.js'
[90m at Function.Module._resolveFilename (internal/modules/cjs/loader.js:966:17)[39m
[90m at Function.Module._load (internal/modules/cjs/loader.js:859:27)[39m
[90m at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)[39m
[90m at internal/main/run_main_module.js:17:47[39m {
code: [32m'MODULE_NOT_FOUND'[39m,
requireStack: []
}
Steps to Reproduce
- Orchestrate any scenario in which the .CMD files will be generated under a path containing "&" character (in theory the other shell metacharacters would also be problematic, see references for an article on windows command line escaping).
Two scenarios come to mind.
Scenario 1: Set NPM Prefix to New Path
- Set npm prefix to "C:/test(n&pm)"
- Globally install mkdirp (or any other binary package).
- Make sure "C:/test(n&pm)" is in your PATH.
- Attempt to run "mkdirp" (or whatever you installed).
Scenario 2: Local Dependencies
- Create an npm package in a folder like "C:/test(n&pm)/package"
- Install a local dependency which has a "bin" entry (like "mkdirp")
- Add a script to package.json which attempts to run the dependency's bin (like
"trymkdir": "mkdirp mytestfolder") - Attempt to run your script:
npm run trymkdir
Expected Behavior
- The .CMD files should be able to run without getting tripped up by shell metacharacters in the path.
Who
- n/a
References
- Everyone quotes command line arguments the wrong way (Microsoft blog explaining cmd quoting and shell metacharacters)
- Dominant language
- JavaScript
- Stars
- 81
- Forks
- 51
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing 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.
More from npm/cmd-shim
-
Needs Triage
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
[BUG] PowerShell shim generated as UTF-8 without BOM breaks on Windows PowerShell 5 with non-ASCII pathsPossibly taken @webywz claimed this 32 days ago. OpenNeeds Triage
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Needs Triage
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
Priority 1
Difficulty 3/5 1-2 days Newbie friendliness 48/100
-
Needs Triage
Difficulty 3/5 1-2 days Newbie friendliness 45/100
Similar issues
-
Flow Needs: Triage :mag:
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
react/react-native#60447 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
erkamyaman/rust-anything#1153 ·
Maintainers usually reply within 1 day
-
Entity picker filter keeps the first kind's groups after switching Specific Term / Specific PostOpenbug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
davidofchatham/bws-gb-dynamic-tags-extensions#177 ·
Maintainers usually reply within 1 day
-
frontend good first issue kind:task level:starter size:s
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Arggon/ArggonStores#42 ·
Maintainers usually reply within 1 day
-
accessibility area: frontend area: i18n beginner-friendly bug difficulty: easy good first issue i18n keyboard priority: P3 quality user-experience
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
Maintainers usually reply within 1 day