Table of Contents
Hello everyone! We will continue a new error today. That is “The upstream dependency conflict installing NPM packages”. As you know, when we use Node.js, we quickly have to install new modules (libraries) because Node is a powerful almost empty module system. So for most operations we have to install additional modules. This is done very easily with the NPM tool. Hopefully, through this article, you will solve the above error and better understand how NPM works.
What is “The upstream dependency conflict installing NPM packages”?
Here is a programmer’s example of this error. While setting up vue-mapbox mapbox-gl on NPM, they were informed that the program had a dependency tree error.
38 error code ERESOLVE
39 error ERESOLVE unable to resolve dependency tree
40 error
41 error While resolving: [1mexample[[email protected][1m1.0.0[22m
41 error Found: [1mmapbox-gl[[email protected][1m1.13.0[22m[2m[22m
41 error [2mnode_modules/mapbox-gl[22m
41 error [1mmapbox-gl[[email protected]"[1m^1.13.0[22m" from the root project
41 error
41 error Could not resolve dependency:
41 error [35mpeer[39m [1mmapbox-gl[[email protected]"[1m^0.53.0[22m" from [1mvue-mapbox[[email protected][1m0.4.1[22m[2m[22m
41 error [2mnode_modules/vue-mapbox[22m
41 error [1mvue-mapbox[[email protected]"[1m*[22m" from the root project
41 error
41 error Fix the upstream dependency conflict, or retry
41 error this command with --force, or --legacy-peer-deps
41 error to accept an incorrect (and potentially broken) dependency resolution.
41 error
41 error See /Users/user/.npm/eresolve-report.txt for a full report.
42 verbose exit 1
Cause of error
If you are in the above situation, we suspect that it may be a bug due to the peer dependency of npm (v7) (latest version is still beta).
How to fix the upstream dependency conflict installing NPM packages
Here are some solutions. Depending on your approach, choose the method that works for you.
Method 1:
You can try to run again with this command line npm install –legacy-peer-deps . Also, if you want to know more you can visit the link
Method 2: Adding force
Import this line:
npm install --force
Method 3: Update npm and audit fix
Run this command:
npm I -g [email protected]
npm audit fix --force
Method 4:
Alternatively, try following these steps:
- Remove the package-lock.json file.
- Modify the package.json ,
- updating the version according to the information provided by the peer dependency
- Run npm install or npm udpate
Conclusion
The above article has given the way to handle when you encounter the error “The upstream dependency conflict installing NPM packages”. Hope it will help you in finding the error and can quickly restart the project. If you still encounter other difficult-to-solve errors, please contact us for a quick response. Thank you for reading!
Leave a comment