[BUG] Unable to install dependencies skipping nested workspaces
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 10.1k
- Forks
- 4.7k
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 19
Description
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
Installing a dependency to a specific workspace that has a sub-workspace (also defined in workspaces array) is adding the dependency to parent (as expected) but is also adding it to all sub-workspaces.
Expected Behavior
If I pass the --workspace flag when using npm i, I expect the dependecy to be added only in such workspace.
Steps To Reproduce
- In this environment...
With this folder structure:
> root
package.json
> workspace-1
package.json
> sub-1
package.json
> sub-2
package.json
You can define it by:
mkdir root && cd root && npm init -y
mkdir workspace-1 && cd workspace-1 && npm init -y
mkdir sub-1 && cd sub-1 && npm init -y && cd ..
mkdir sub-2 && cd sub-2 && npm init -y && cd ../..
- With this config...
Adding this entry to root/package.json:
"workspaces": [
"workspace-1",
"workspace-1/sub-1",
"workspace-1/sub-2"
]
- Run '...'
cd root
npm i dependency -w workspace-1 --save
- See error...
dependency is correctly added to workspace-1 but is also added to workspace-1/sub-1 and workspace-1/sub-2.
Environment
- npm: 8.12.1
- Node.js: v16.14.2
- OS Name: Windows 10 Pro
- System Model Name: Notebook Dell Latitude 3400
- npm config:
; "builtin" config from C:\Program Files\nodejs\node_modules\npm\npmrc
prefix = "C:\\Users\\gv_******\\AppData\\Roaming\\npm"
; "user" config from C:\Users\gv_******\.npmrc
package-lock = true
strict-ssl = false
; node bin location = C:\Program Files\nodejs\node.exe
; cwd = C:\Programming\workspaces\lnk\architecture\nested-ws
; HOME = C:\Users\gv_******
; Run `npm config ls -l` to show all defaults.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the nested workspace layout and running npm i dependency -w workspace-1 --save from the root. Verify the dependency is added to workspace-1 but not to workspace-1/sub-1 or workspace-1/sub-2; use the workspace selection and dependency-installation entry points involved in that command.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100