npm/cli

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

jansiegel opened this issue · 2 comments

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

Is there any ETA for this?

In my case, I can't even run scripts in the nested workspaces; npm says "no workspaces," although they are listed.

root/
├─ moon/
│  ├─ front/
│  │  ├─ package.json
│  ├─ package.json <-- npm run build -w front
├─ package.json
{
  "name": "@moon/monorepo",
  "workspaces": [
    "front"
  ],
  "scripts": {
    "build": "npm run -w front build"
  }
}