npm / cli

the package manager for JavaScript
https://docs.npmjs.com/cli/
Other
8.33k stars 3.07k forks source link

[ENHANCEMENT] Please update this warning to be more clear. #7042

Open danshome opened 9 months ago

danshome commented 9 months ago

Is there an existing issue for this?

This issue exists in the latest npm version

Current Behavior

npm ERR! code ERESOLVE npm ERR! ERESOLVE unable to resolve dependency tree npm ERR! npm ERR! While resolving: @com.txdot.cris/ui@0.0.0 npm ERR! Found: @angular/common@16.2.12 npm ERR! node_modules/@angular/common npm ERR! @angular/common@"^16.2.12" from the root project npm ERR! npm ERR! Could not resolve dependency: npm ERR! peer @angular/common@"^17.0.3" from angular-google-tag-manager@1.9.0 npm ERR! node_modules/angular-google-tag-manager npm ERR! angular-google-tag-manager@"^1.8.0" from the root project

This error always leads our developers down the wrong path trying to troubleshoot npm. They usually start by pointing at npm or Nexus. Why? Because it says "Could not resolve dependency:" they immediately think it can't find the dependency in Nexus or the npm repos. What it really means is that there is a dependency conflict because angular-google-tag-manager 1.9.0 depends on Angular 17, and we are using Angular 16. If it said, "Could not resolve a peer dependency conflict:" it would help a lot.

Expected Behavior

N/A

Steps To Reproduce

N/A

Environment

N/A

Den-dp commented 9 months ago

I wonder what else can be done to improve the overall readability.

Cause according to SO, it is difficult to understand: https://stackoverflow.com/questions/76039613/how-to-read-npm-dependency-errors https://stackoverflow.com/questions/68217049/how-do-you-read-npm-audit-eresolve-error https://stackoverflow.com/questions/72614420/npm-err-code-eresolve-npm-err-eresolve-could-not-resolve-npm-err-while-resolv

Want to believe that there is a way to make it less overwhelming

Blaumaus commented 8 months ago

How about something like:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! Conflicting dependencies while resolving @com.txdot.cris/ui@0.0.0:
npm ERR! Found @angular/common v16.2.12 required by root project 
npm ERR! but angular-google-tag-manager v1.9.0 requires @angular/common ^17.0.3
npm ERR!

Would be happy to update the error message to something like that in a PR