npm / npm/cli

[BUG] not installing peer dependencies for workspaces if they are not nested inside the root package

Open
#2,650 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Documentation Enhancement Release 7.x
Dominant language
JavaScript
Stars
10.1k
Forks
4.7k
Avg merge
2d 2h
Merged PRs (30d)
19

Description

Current Behavior:

having 'library-project' with peer-dependencies adjacent to 'main-project'
and 'main-project' with workspaces: ['../library-project'] (outside of 'main-project' folder)
'npm install' in 'main-project' is not installing the peer-dependencies

example:

library-project/
  package.json      // peerDependencies: {"dep-a": "1.0.0"}
main-project/
  package.json      // "workspaces": [ "../library-project" ]
Expected Behavior:

expecting node_modules in 'main-project' after 'npm i' to include 'dep-a':

node_modules
  library-project (linked)
  dep-a

actual result: missing 'dep-a' in node_modules

this works fine if 'library-project' would be inside 'main-project'

Steps To Reproduce:
  1. main-project and library-project are two adjacent projects

  2. main-project package.json:

{
  "name": "main-project",
  "version": "1.0.0",
  "workspaces": [
    "../library-project"
  ],
  "dependencies": {
    "library-project": "1.0.0"
  }
}
  1. library-project package.json:
{
  "name": "library-project",
  "version": "1.0.0",
  "peerDependencies": {
    "@angular/core": "11.1.2"
  }
}
  1. run 'npm install' in 'main-project'

  2. expected "@angular/core" to be installed as it's a peer dependency of 'library-project'

Environment:
  • Node: 15.6.0
  • npm: 7.5.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

Reproduce the issue with adjacent main-project and library-project directories using the package.json files and npm 7.5.2 described here. Start by tracing workspace linking and peer-dependency installation for a workspace outside the root; done when running npm install in main-project installs the library project's peer dependency, such as @angular/core, in main-project/node_modules.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.