npm / npm/cli

[BUG] npm run-script environment variables with embedded equal sign in value not working in windows

Open
#6,261 0 comments 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.