Unable to resolve dependency tree error when installing npm packages
Solution 1:
This is not related to an HTTP proxy.
You have dependency conflict (incorrect and potentially broken dependency) as it says, so try to run the command with --force
, or --legacy-peer-deps
. If it doesn't take effect, the temporary solution is using prior versions of the Node.js (downgrading the Node.js version) as it causes this kind of errors to happen sometimes.
Update based on the OP's update:
As you see, it fires the following error:
No matching version found for @angular/http@^9.1.4.
Take a look at angular/http
page. Note that the latest version for that deprecated package is 7.2.16
while you request an upper version (e.g., ^9.1.4
)! So, try to check the project dependencies and follow the raised errors in order to solve the problem.
Solution 2:
Try this command-
npm install --save --legacy-peer-deps
Solution 3:
In addition to using the --legacy-peer-deps
command line option, this can also be set more permanently as a config option:
npm config set legacy-peer-deps true
Solution 4:
When using npm
7, this comes up a lot because peer dependencies issues are treated as errors in version 7 whereas they were generally only warnings in version 6. Usually using --legacy-peer-deps
makes it work with npm
7.
When that doesn't work, an option is to downgrade to npm
6. Downgrading Node.js is not necessary (but not harmful either). The relevant dependency management code is in npm
. Downgrading Node.js will often work coincidentally because doing so will often downgrade npm
as well.
Another option that is less disruptive than downgrading npm
is using npx
to use the previous version of npm
for just the install command: npx -p npm@6 npm install
And when all else fails, it's often worth a shot to remove the node_modules
directory and package-lock.json
, and then run npm install
again. That regenerates node_modules
and package-lock.json
.