Skip to content

[BUG] Arguments are not correctly passed from CLI to npm script when --workspace is used (npm 11.4.2, Windows, Powershell) #8398

@sap-sebelao

Description

@sap-sebelao

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

Attempting to use --workspace argument seems to bring back the issue described in
#3136
and supposedly fixed in
#8278

Example using PowerShell
npm run start --workspace=my_package -- "foo" -b "bar" -c "baz"

start inside the package is defined as
node dist/cli.js

Results in
node dist/cli.js "foo" "bar"

  • the "foo" argument is fine
  • the "-b" option is missing but its value "bar" remains
  • the "-c" option is removed completely

Sorry for a not more concrete example but this is happening in an internal project, I hope these examples are clear enough to recreate the situation.

For now a workaround for us is to run from the package folder.

Expected Behavior

In CLI
npm run start --workspace=my_package -- "foo" -b "bar" -c "baz"

start inside the package is defined as
node dist/cli.js

Should result in
node dist/cli.js "foo" -b "bar" -c "baz"

Steps To Reproduce

  1. Have a monorepo with multiple packages
  2. Define a start script in the package.json of the package, make it call js code that reads CLI arguments
  3. From the monorepo root, try to run the script using --workspace argument for npm
  4. Observe how arguments are passed to the package start script

Environment

  • npm: 11.4.2
  • Node.js: 24.3.0
  • OS Name: Windows 11
  • System Model Name:
  • npm config:
npm error code ENOWORKSPACES
npm error This command does not support workspaces.

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