npm / npm/cli

[BUG] Installing dependencies of nested workspaces seems to not work properly in version 8.5+

Open
#4,774 4 comments 49 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Needs Triage Release 8.x
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

In my repository, I have a nested workspace structure that looks something like this:

root/
├─ test-1/
│  ├─ test-1a/
│  │  ├─ package.json
│  ├─ test-1b/
│  │  ├─ package.json
│  ├─ package.json
├─ test-2/
│  ├─ package.json
├─ package.json
  1. ./package.json defines the directories test-1 and test-2 as workspaces
  2. ./test-1/package.json defines the directories test-1a and test-1b as workspaces
  3. These directories have their own dependencies:
    • ./test-1a
    • ./test-1b
    • ./test2

The problem: Running npm install in ./test-1 doesn't result in installing dependencies from test-1a and test-1b in ./test-1/node_modules. The only thing that happens is symlinking ./test-1 in ./node_modules.

Expected Behavior

In versions up to 8.4.x, running npm install in a nested workspace (directory with is both a workspace for a parent directory and defines its own workspaces) resulted in installing the dependencies from workspaces defined in its package.json to ./path-to-nested-workspace/node_modules.

Steps To Reproduce

I created a repo with the setup I'm explaining.

Either see a workflow that installs dependencies of a nested workspace for 3 different npm versions:

  1. https://github.com/jansiegel/nested-workspace-dependencies/actions/runs/2189924517

Or:

  1. Clone https://github.com/jansiegel/nested-workspace-dependencies
  2. Run npm install in the root directory
  3. cd test1
  4. npm install
  5. See what was installed
Environment
  • npm: 8.5.0+
  • Node.js: v16.14.2

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the nested-workspace reproduction repository and its package.json files, then run the listed npm install steps with the affected npm versions. Compare the resulting node_modules contents and symlinks in test1 and its nested workspaces; done means dependencies from test-1a and test-1b are installed as expected.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs
Domain
cli, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.