[BUG] npm run on Windows mishandles backslash escaping
Open
Nobody has claimed this yet.
Bug
- 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
This issue exists in the latest npm version
- I am using the latest npm
Current Behavior
package.json
{
"scripts": {
"test": "printf '%s' '\\\\' | od -c"
}
}
Using npm run
$ npm run test
> test
> printf '%s' '\\' | od -c
0000000 \
0000001
Using git-bash
$ printf '%s' '\\' | od -c
0000000 \ \
0000002
Expected Behavior
$ npm run test
> test
> printf '%s' '\\' | od -c
0000000 \ \
0000002
In Linux (Ubuntu 24.04.2 LTS) this works as expected
Steps To Reproduce
See Current Behavior section
Environment
- npm: 11.11.1
- Node.js: v24.14.0
- OS Name: Windows 11 Pro
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
Reproduce the package.json script with npm run on Windows 11, then compare its output with direct git-bash and Ubuntu runs. Trace the npm run command path involved in Windows argument escaping; done means the backslash is preserved and od -c reports the expected two-byte output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100