cli icon indicating copy to clipboard operation
cli copied to clipboard

[BUG] `--` separator not passing arguments to scripts on Windows

Open craxal opened this issue 2 weeks 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

Arguments are passed to the script when run on Mac:

process.argv: [
  "/path/to/node",
  "/path/to/test.js",
  "--my-arg=value"
]

Arguments are not passed to the script when run on Windows:

process.argv: [
  "C:\\Program Files\\nodejs\\node.exe",
  "C:\\path\\to\\test.js"
]

The --my-arg=value is completely missing from process.argv.

Additionally, npm shows a warning:

npm warn Unknown cli config "--my-arg". This will stop working in the next major version of npm.

This suggests npm is treating the argument as an npm config option despite it appearing after --.

Expected Behavior

Arguments after -- should be passed to the script, regardless of platform:

process.argv: [
  "/path/to/node",
  "/path/to/test.js",
  "--my-arg=value"
]

Steps To Reproduce

  1. Create a minimal test project:

    {
      "name": "npm-args-test",
      "version": "1.0.0",
      "scripts": {
        "test-args": "node test.js"
      }
    }
    
    // test.js
    console.log('process.argv:', JSON.stringify(process.argv, null, 2));
    
  2. Run the command with arguments:

    npm run test-args -- --my-arg=value
    

    Observe the output.

Environment

  • npm: 11.x
  • Node.js: 22.x
  • OS Name: Windows 11/macOS Tahoe
  • System Model Name: N/A
  • npm config:
; "builtin" config from REDACTED

prefix = REDACTED

; "user" config from C:\Users\cralvord\.npmrc

REDACTED
email = (protected)
script-shell = "pwsh"

; "project" config from REDACTED

always-auth = true
registry = REDACTED

; node bin location = C:\Program Files\nodejs\node.exe
; node version = v22.13.0
; npm local prefix = REDACTED
; npm version = 11.7.0
; cwd = REDACTED
; HOME = REDACTED
; Run `npm config ls -l` to show all defaults.

craxal avatar Dec 11 '25 20:12 craxal