Angular-GettingStarted: "Unable to resolve dependency tree" error during NPM install of APM-Start

I am using the Angular: Getting Started Pluralsight lesson and I am attempting to run npm install on the APM-Start folder found in the repository. I am receiving this error message, not entirely sure what it means but I think it might indicate a mismatched version somewhere? I have some experience with npm in the past, though I’ve never been good at troubleshooting it.

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: apm@0.0.0
npm ERR! Found: @angular/compiler@10.0.14
npm ERR! node_modules/@angular/compiler
npm ERR!   @angular/compiler@"~10.0.4" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/compiler@"10.2.4" from @angular/compiler-cli@10.2.4
npm ERR! node_modules/@angular/compiler-cli
npm ERR!   peer @angular/compiler-cli@">=10.0.0-next.0 < 11" from @angular-devkit/build-angular@0.1000.8
npm ERR!   node_modules/@angular-devkit/build-angular
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.
npm ERR! 
npm ERR! See /Users/robert.anderson/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/robert.anderson/.npm/_logs/2021-01-05T18_17_06_138Z-debug.log

How would I resolve this issue?

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 18
  • Comments: 31 (9 by maintainers)

Commits related to this issue

Most upvoted comments

Did you see any errors after running npm install?

Did you run npm audit fix? Running the fix will cause a mismatch with your versions, so it should not be run.

Try this:

  1. Delete node_module folder and the package-lock.json file.
  2. Run npm cache verify to verify and clean up your npm.
  3. Run npm install again. (Do NOT run npm audit fix)
  4. Run npm start

Let me know if that resolves the issue.

I haven’t seen that error before.

Had you done anything else? Or installed anything else into that folder?

What version of node and npm do you have?

Reading this: https://stackoverflow.com/questions/64573177/unable-to-resolve-dependency-tree-error-when-installing-npm-packages

Suggests trying:

  • npm install --force
  • npm install --legacy-peer-deps

But I don’t know why you would suddenly see this. The dependencies in the package.json file should all be compatible unless something else was installed to modify it.

EDIT: If you want to continue with the course without having to install anything, try using stackblitz as per the instructions here: https://github.com/DeborahK/Angular-GettingStarted#stackblitz

Just in case, I did have similar behavior, when I tried either npm upgrade my current Angular 11.x based boilerplate from previous ng new or create new ng new abc based on Angular 12.x. I simply forgot to upgrade Angular CLI. So this npm install -g @angular/cli@latest solved my errors during ng new abc.

我的是node版本太高了,重新安装对应版本就行

Got this error in my personal repo

It looks like it happened to me due to the new version of lock file which was not supported by a lower version of npm.

I also got the following message:

npm WARN read-shrinkwrap This version of npm is compatible with lockfileVersion@1, but package-lock.json was generated for lockfileVersion@2. I'll try to do my best with it!

deleting the node_modules and re-generating lock file helped in my case.

The error I posted is the error that occurs when I attempt to run npm install. It doesn’t appear that a package-lock or node_modules folder even got generated in the project folder. I have not run npm audit fix at any point.

I decided to run npm cache verify anyway to see what happened, this was the output.

robert.anderson@ATGs-MBP APM-Start % npm cache verify
Cache verified and compressed (~/.npm/_cacache)
Content verified: 1525 (84613636 bytes)
Content garbage-collected: 1 (987145 bytes)
Index entries: 1525
Finished in 4.157s

npm install still fails with the same error after running this.

I haven’t seen that error before.

Had you done anything else? Or installed anything else into that folder?

What version of node and npm do you have?

Reading this: https://stackoverflow.com/questions/64573177/unable-to-resolve-dependency-tree-error-when-installing-npm-packages

Suggests trying:

  • npm install --force
  • npm install --legacy-peer-deps

But I don’t know why you would suddenly see this. The dependencies in the package.json file should all be compatible unless something else was installed to modify it.

EDIT: If you want to continue with the course without having to install anything, try using stack blitz as per the instructions here: https://github.com/DeborahK/Angular-GettingStarted#stackblitz

I have tried this one, and it’s working fine without any errors. Thanks!!

@amit-jadhav This github repo contains the code for my Angular: Getting Started course. It doesn’t look like the code you are compiling is from this course.

If you have a more general Angular question, please post to stackoverflow.com.

That said, reading your error message, it sounds like your Angular project is v8, but your ag-grid is looking for Angular v9. It’s important to ensure you have appropriate versions of third party components that match the version of Angular you have. (Angular is now on v13)

Hope you can resolve your issue.

What version of the Angular CLI are you using? When you updated the Angular CLI version, did you update the version of the Angular libraries in the project as well? (The locally installed version of the Angular CLI should match with its associated version of the Angular libraries in the project.)

What happens if you delete your package-lock.json file and your node-modules folder and you re-run npm install again?

Hi Deborah, actually I was able to fix the issue and I landed on this page from someone else’s tutorial that was giving me the same error as HJosh had, but what I did to fix my environemnt was copy package.json dependency sections with up-to-date values, deleting node_modules/ and pakcage-lock.json, and running npm install with the --legacy-peer-deps flag.

it is because of a compatibility issue between npm and ng

Thank you for the additional information. I’ll spend some more time on it today, trying it on several machines, and I’ll update the code as needed.

I talked to a coworker who was also taking the course and was encountering the same issue. He had figured out that updating the Angular dependencies to the latest 10.x release (~10.2.4 for most @angular dependencies, @angular/cli on ~10.2.1) resolved the problem, and npm install now runs successfully.

I could make a PR with the package.json updates, though if it’s not reproducible on machines other than the two of ours it’s probably worth investigating more before applying a fix. Versions of potentially relevant things below:

OS: Mac OSX Big Sur 11.1 node -v: v15.5.1 npm -v: 7.3.0 nvm -v: 0.37.2

Let me know if there’s any other information I could provide that might help.