Open rogerfar opened 2 years ago
this one is interesting, so i'm going to walk through it step by step.
if i run npm i
i get
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: client@1.0.0
npm ERR! Found: @angular/common@13.2.5
npm ERR! node_modules/@angular/common
npm ERR! @angular/common@"^13.2.4" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/common@"^12.0.0" from ngx-monaco-editor@12.0.0
npm ERR! node_modules/ngx-monaco-editor
npm ERR! ngx-monaco-editor@"^12.0.0" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
which is telling us that the peer dependency for @angular/common
specified by ngx-monaco-editor
conflicts with the version of @angular/common
specified in the package.json
. we can get around this by using either the --legacy-peer-deps
flag, or the --force
flag.
the result of npm i --legacy-peer-deps
is:
npm ERR! code ETARGET
npm ERR! notarget No matching version found for typescript@4.6.0.
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.
this happens because your root package is depending on typescript
at the specific version 4.6.0
, which appears it was never published as only prerelease versions of 4.6.0 exist in the npm registry. if i change the root requirement for typescript to either 4.5.5
or 4.6.2
which are published versions available in the registry, then npm i --legacy-peer-deps
finishes successfully.
the other suggestion offered in the error message above is to use --force
, which is what triggers this issue because we skip our normal dependency resolution and try to force typescript@4.5.5
instead of the 4.6.0
specified in the package.json
. however, it does appear we have a bug in how we handle dependencies that we've overwritten due to the --force
flag causing this infinite loop.
the fix for your specific use case is to change your typescript
dependency to a version available in the npm registry and to run npm install --legacy-peer-deps
. npm i --force
also works correctly after correcting the typescript requirement, though i would lean heavily toward using --legacy-peer-deps
and avoiding --force
as much as possible due to other protections it disables.
i'm going to leave this issue open to track the work of fixing the infinite loop when using --force
while specifying a package version that doesn't exist.
Is there an existing issue for this?
This issue exists in the latest npm version
Current Behavior
The following infinite recursion occurs when doing npm install:
Expected Behavior
No response
Steps To Reproduce
Environment