Skip to content

[BUG] npm-run: Running a command in the context of a workspace, also runs the command in the context of workspaces residing in subfolders of the first workspace #8771

@sangafabrice

Description

@sangafabrice

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-run: Running a command in the context of a workspace, also runs the command in the context of workspaces residing in subfolders of the first workspace.

Expected Behavior

npm-run: Running a command in the context of a workspace, should only run the command of that workspace. The steps to reproduce described below should ouput:

> test
> echo test from build

test from build

Steps To Reproduce

  1. In this environment:
root
│   package.json
│
└───build
    │   package.json
    │
    └───minify
            package.json
  1. With this config:

root/package.json

{
  "name": "root",
  "workspaces": [ "build", "build/minify" ]
}

root/build/package.json

{
  "name": "build",
  "scripts": {
    "test": "echo test from build"
  }
}

root/build/minify/package.json

{
  "name": "@build/minify",
  "scripts": {
    "test": "echo test from build/minify"
  }
}
  1. Run
npm run test --workspace=build
  1. See error:
> test
> echo test from build

test from build

> test
> echo test from build/minify

test from build/minify

Environment

  • npm: 11.6.3
  • Node.js: 24.11.1
  • OS Name: Windows 10 22H2
  • System Model Name: Lenovo Legion Y520
  • npm config:
; "builtin" config from C:\Users\username\AppData\Roaming\npm\node_modules\npm\npmrc

prefix = "C:\\Users\\username\\AppData\\Roaming\\npm"

; node bin location = C:\nvm4w\nodejs\node.exe
; node version = v24.11.1
; npm local prefix = C:\root
; npm version = 11.6.3
; cwd = C:\root
; HOME = C:\Users\username
; 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