npm / npm/cli

[BUG] peerDependency not installed (workspaces)

Open
#4,084 5 comments 2 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

Refs https://github.com/npm/cli/issues/2600

I am using NPM workspaces.
I moved all my dev dependencies to the root package.json (because I was running into https://github.com/npm/cli/issues/4056)

devDependencies: {
   ...
   "mssql": "^7.1.0",
   "knex": "^0.21.21",
   ....
}

knex@0.21 has a peerDependency to mssql@6 (see)

I am getting an error when running npm install

npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: @projectname/root@undefined
npm ERR! Found: mssql@7.1.0
npm ERR! node_modules/mssql
npm ERR!   dev mssql@"^7.1.0" from the root project
npm ERR!   peerOptional mssql@"*" from typeorm@0.2.41
npm ERR!   node_modules/typeorm
npm ERR!     dev typeorm@"^0.2.37" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! dev knex@"^0.21.21" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: mssql@7.3.0
npm ERR! node_modules/mssql
npm ERR!   peerOptional mssql@"^6.2.1" from knex@0.21.21
npm ERR!   node_modules/knex
npm ERR!     dev knex@"^0.21.21" from the root project

I tried --legacy--peer-deps, but this is not what I want. This flag will just ignore the peer dependency. Knex will then use mssql@7!

Expected Behavior

I expected that npm provides a way to install both versions.

node_modules
    mssql@7
    knex
        node_modules
            mssql@6
Steps To Reproduce

See above.

Environment
  • npm: 8.1.4
  • Node: v16.13.0
  • OS: Monterey
  • platform: OSX

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 by reproducing the workspace installation scenario described with npm 8.1.4, Node v16.13.0, knex@0.21.21, and mssql@7.1.0. Investigate npm's peer-dependency resolution for workspaces and verify completion by checking whether compatible dependency versions are installed without requiring --legacy-peer-deps.

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
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.