Skip to content

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

@craxal

Description

@craxal

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

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 REDACTED

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixingNeeds Triageneeds review for next steps

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions