[Fix] npm ERR ERESOLVE unable to resolve dependency tree

The Error “npm ERR! ERESOLVE unable to resolve dependency tree “, is an error that is invoked whenever you are coding in angular.js and using the npm i command. Given below is the snippet of the error you might get:

npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: project-admin@11.0.0
npm ERR! Found: @angular/common@11.0.3
npm ERR! node_modules/@angular/common
npm ERR!   @angular/common@"11.0.3" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/common@"^9.1.0 || ^10.0.0" from @agm/core@3.0.0-beta.0
npm ERR! node_modules/@agm/core
npm ERR!   @agm/core@"3.0.0-beta.0" from the root project

I would like to share with you the steps I took to fix the “npm ERR! ERESOLVE unable to resolve dependency tree ” in your project file.

Why “npm ERR ERESOLVE unable to resolve dependency tree ” Error is Seen?

The error, “npm ERR! ERESOLVE unable to resolve dependency tree ” is seen because you have a dependency conflict, that is caused due to incorrect or potentially broken dependencies as it says. To validate this, try to run the command with --force, or --legacy-peer-deps and see if has any effects to the error.

The detailed solution to fix the error “npm ERR! ERESOLVE unable to resolve dependency tree “, is given below:

How to fix npm ERR ERESOLVE unable to resolve dependency tree Error ?

To fix the npm ERR ERESOLVE unable to resolve dependency tree error, you will have to downgrade your node version to node.js version 14. You can also use Yarn to force install packages.

You can also downgrade your Angular and the global Angular CLI version to version 12 or you may have to downgrade your package version which may be compatible with the Angular version you are using.

To fix the error, “npm ERR! ERESOLVE unable to resolve dependency tree “, you have to follow the one of the below mentioned method:

Method 1: Downgrade your node version

To fix the error you have to downgrade your node version to node.js version 14. Along with the node version also try to downgrade your dependencies to work with node 14

This should fix the error, “npm ERR! ERESOLVE unable to resolve dependency tree “.

Method 2: Force install packages with yarn

You can fix the error by forcing yarn to install a package by following the below mentioned command:

yarn remove dependency
yarn add file:/dependency

This should fix the error, “npm ERR! ERESOLVE unable to resolve dependency tree “.

Method 3: Downgrading Angular and the global Angular CLI

To fix the error you have to downgrade Angular and the global Angular CLI version to version 12 or any other version that will satisfy the requirements of your project.

There is chance that the version of package you have installed in your project which might be causing the error. So upgrading your packages to the latest versions should fix the error.

This should fix the error, “npm ERR! ERESOLVE unable to resolve dependency tree “.

Conclusion

To fix the error “npm ERR! ERESOLVE unable to resolve dependency tree “, you will have to downgrade your node version to node.js version 14.

You can also use Yarn to force install packages. You can also downgrade your Angular and the global Angular CLI version to version 12 or you may have to downgrade your package version which may be compatible with the Angular version you are using.