cli icon indicating copy to clipboard operation
cli copied to clipboard

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

Open mkropf opened this issue 3 years ago • 0 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

This issue exists in the latest npm version

  • [X] 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

mkropf avatar Mar 16 '23 11:03 mkropf