cli
cli copied to clipboard
[BUG] installing a package with incompatible peer dependencies and `--force` sometimes results in an inf. loop
Is there an existing issue for this?
- [X] I have searched the existing issues
This issue exists in the latest npm version
- [X] 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/[email protected]
npm WARN node_modules/@eslint-community/eslint-utils
npm WARN @eslint-community/eslint-utils@"^4.2.0" from @typescript-eslint/[email protected]
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
- Clone https://github.com/testing-library/eslint-plugin-jest-dom
- Run
npm i eslint@9 --force
- 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
It seems that if I remove the explicit dependency on @typescript-eslint/parser
then the inf. loop is resolved even though the same resulting version of @typescript-eslint/parser
is installed due to child dependencies
Reproduction steps:
- create a new project
{
"name": "eslint-plugin-jest-dom",
"version": "0.1.0",
"dependencies": {
"@typescript-eslint/parser": "^5.9.1",
"eslint": "^9.2.0",
"kcd-scripts": "^12.0.0"
}
}
-
npm install --force
-
npm install eslint@9 --force
- see the infinite logs
~Tested against latest
and this is no longer happening w/ the example repo. This was fixed by https://github.com/npm/cli/pull/7499~
Sorry, missed the eslint@9
step. This is still happening.
The issue is in build-ideal-tree.js the buildDepStep() function is basically have code to check depsQueue if the queue has some dependency, it is recursively calling buildDepStep().. In this scenario the queue is never getting empty because of which it is going in infinite loop. Since it’s not resolving proper dependency it keeps on adding. We need to find some break conditions if someone is using --force in command.