When you try to install an Angular or React JS application you may get the error message “ERESOLVE unable to resolve dependency tree error” in your command prompt.

The reason for the error message is because of a dependency conflict. Starting from npm version 7, whenever it comes across peerDependency conflict, it will through the error message.

There are couple of solutions to the above problem:

If you got the above error message while installing a new Angular or React JS application, first ‘cd’ into that directory. That is because, earlier npm (or ng new) command created the directory and package.json files, but not installed the node modules. So, we need to navigate into that directory and install node packages.

Solution 1:

use “–legacy-peer-deps” with npm command which tells npm to ignore all peerDependecies

Copy to Clipboard

Solution 2:

use “–force” with npm which tells npm to fetch the resources from its repository even when you have a copy in the local machine.

Copy to Clipboard

Solution 3:

You can also downgrade your npm to a version less than 7. (note that the following command install npm version 6.14.13 on your system globally, if you want to install it in a particular application, omit -g from the command)

Copy to Clipboard

 

If you got the error message “ERESOLVE unable to resolve dependency tree error” even while installing a npm package, then also you can use any of the solution provided above.