[BUG] npm run-script environment variables with embedded equal sign in value not working in windows
Open
Nobody has claimed this yet.
Bug
Priority 2
Release 9.x
- 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
npm puts package.json entries into the environment in which it runs scripts, but in windows, with cmd.exe shell, values that contain an = are wrongly parsed:
{
"name": "test",
"engines": {
"node": "^18.13.0",
"npm": ">=9.6.1"
},
"scripts": {
"test1": "echo %npm_package_engines_node%",
"test2": "echo %npm_package_engines_npm%",
"test3": "echo %npm_package_engines_npm=>%"
}
}
npm run <testname> produces the following results:
- test1 - correct value
- test2 - no output for key that should exist
- test3 - output for key that should not exist
Maybe it's an issue with cmd.exe?
Expected Behavior
No response
Steps To Reproduce
run given package.json in windows
Environment
- npm: 9.6.1
- Node.js: 18.13.0
- OS Name: Windows 10.0.22000.1696
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
No source file or test is named. Start by reproducing the package.json example with npm 9.6.1 and Node.js 18.13.0 on Windows 10 using cmd.exe; done means environment variables whose values contain '=' are exposed under the correct names and values, with regression coverage for the behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nodejs, shell
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100