3

I often receive error ERESOLVE similar to below. How do you read it?

>npm audit fix
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: myapp@0.0.0
npm ERR! Found: @angular/compiler@12.1.0
npm ERR! node_modules/@angular/compiler
npm ERR!   @angular/compiler@"12.1.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/compiler@"12.1.1" from @angular/compiler-cli@12.1.1
npm ERR! node_modules/@angular/compiler-cli
npm ERR!   dev @angular/compiler-cli@"^12.1.0" from the root project
npm ERR!   peer @angular/compiler-cli@"^12.0.0 || ^12.1.0-next" from @angular-devkit/build-angular@12.1.0
npm ERR!   node_modules/@angular-devkit/build-angular
npm ERR!     dev @angular-devkit/build-angular@"12.1.0" from the root project

And how do you read it - Which package depends on which? Which end of the tree I have control of? Top or bottom?

Did I add @angular-devkit/build-angular into my app and it needs but cant find angular/compiler ? or is it the other way around?

Boppity Bop
  • 9,613
  • 13
  • 72
  • 151
  • It seems you are meeting the dependency conflict (incorrect and potentially broken dependency) issue, try to run the command with `--force`, or `--legacy-peer-deps`, such as: `npm audit fix --force`. If it doesn't take effect, the temporary solution is using prior versions of the node (Downgrading node version) as it causes to happen such this kind of errors sometimes. Reference: [Unable to resolve dependency tree error when installing npm packages](https://stackoverflow.com/questions/64573177/unable-to-resolve-dependency-tree-error-when-installing-npm-packages). – Zhi Lv Jul 02 '21 at 05:59
  • its not what i need really. I edited the question.. – Boppity Bop Jul 03 '21 at 12:49

2 Answers2

1

I can be wrong but this is what I read:

Which package depends on which?

Your app directly depends on:

  • @angular/compiler@"12.1.0"
  • @angular/compiler-cli@"^12.1.0"
  • @angular-devkit/build-angular@"12.1.0"

Your app transitively depends on:

  • @angular/compiler@"12.1.1" from @angular/compiler-cli@12.1.1 <- which is the actual @angular/compiler-cli version installed in your node_modules.
  • @angular/compiler-cli@"^12.0.0 || ^12.1.0-next" from @angular-devkit/build-angular@12.1.0 <- which is the actual @angular-devkit/build-angular version installed in your node_modules.

So what I read is that there is a conflict because your app directly depends on @angular/compiler@"12.1.0" and transitively on @angular/compiler@"12.1.1" (from @angular/compiler-cli@12.1.1) You can probably fix this by adding what it looks like a missing caret, ie @angular/compiler@"^12.1.0".

Unrelated ^, I had a similar problem but all versions where compatible. I deleted package-lock.json and node_modules and installed them again and it worked fine.

mike
  • 1,956
  • 16
  • 22
0

I've fixed it with following commands:

  1. rm package-lock.json
  2. rm -rf node_modules
  3. yarn install
  4. npm i
pafede2
  • 1,626
  • 4
  • 23
  • 40