npm / npm/cli

[BUG] installing a package with incompatible peer dependencies and `--force` sometimes results in an inf. loop

Open
#7,349 5 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Priority 2
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

On https://github.com/testing-library/eslint-plugin-jest-dom/commit/18afe30adab44a1c3fa96b9669b299178c5517b2 doing npm i eslint@9 --force results in an inf. loop outputting:

npm WARN node_modules/eslint
npm WARN   peer eslint@"^6.0.0 || ^7.0.0 || >=8.0.0" from @eslint-community/eslint-utils@4.4.0
npm WARN   node_modules/@eslint-community/eslint-utils
npm WARN     @eslint-community/eslint-utils@"^4.2.0" from @typescript-eslint/utils@5.62.0
npm WARN     node_modules/@typescript-eslint/utils
npm WARN     1 more (eslint)
npm WARN   17 more (@typescript-eslint/eslint-plugin, ...)
npm WARN 
npm WARN Could not resolve dependency:

Related PR: https://github.com/testing-library/eslint-plugin-jest-dom/pull/355

Expected Behavior

The install to complete fine, since I've --force'd it

Steps To Reproduce
  1. Clone https://github.com/testing-library/eslint-plugin-jest-dom
  2. Run npm i eslint@9 --force
  3. Get stuck in a loop

(also see https://github.com/testing-library/eslint-plugin-jest-dom/actions/runs/8586049626/job/23528114426?pr=355)

Environment
  • npm: 10.5.1
  • Node.js: v16.20.2 (also at least happens on 18 too)
  • OS Name: Ubuntu
  • System Model Name: -
  • npm config: -
; copy and paste output from `npm config ls` here

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 issue with npm i eslint@9 --force in the linked eslint-plugin-jest-dom commit, using the reported npm and Node.js versions. Trace the npm CLI dependency-resolution path responsible for repeated peer-dependency warnings; done means the forced install completes without looping, while preserving the expected dependency handling.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.