Is there an existing issue for this?
This issue exists in the latest npm version
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
- In this environment:
root
│ package.json
│
└───build
│ package.json
│
└───minify
package.json
- 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"
}
}
- Run
npm run test --workspace=build
- 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.