npm install error while use webpack, Could not resolve dependency - node.js

The error as follows:
> npm install
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! Found: webpack#3.12.0
npm ERR! node_modules/webpack
npm ERR! dev webpack#"^3.5.6" from the root project
npm ERR! peer webpack#"2 || 3 || 4" from _babel-loader#7.1.5#babel-loader#7.1.5
npm ERR! node_modules/_babel-loader#7.1.5#babel-loader
npm ERR! 5 more (_html-webpack-plugin#2.30.1#html-webpack-plugin, ...)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer webpack#"^2.0.0" from _strip-pragma-loader#1.0.0#strip-pragma-loader#1.0.0
npm ERR! node_modules/_strip-pragma-loader#1.0.0#strip-pragma-loader
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See /home/agou-ops/.npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/agou-ops/.npm/_logs/2021-04-12T02_49_11_062Z-debug.log
debug.log file content:
packge version and system
npm: 7.6.3
webpack: 3.12.0
system: Ubuntu 20.04
How should I fix it?

npm#7 has stricter dependency resolution than previous versions. If you can update the version of webpack in your root project, that may resolve it. An alternative easy quick thing to try is npm install --legacy-peer-deps.

I met the same problem.
try to run the command with --force , if you don't use the related package.
e.g.
npm install --verbose --force

For npm v7+. It is due to missing dependencies for entries mentioned in the package.json file
use:
npm i --force
or
npm i --legacy-peer-deps
to override peer dependency.
Answered in

Downgrade to a lower npm version with, for example,
npm install npm#6

Related

I'm getting the following error while typing npm install and trying to do project setup? [duplicate]

This question already has an answer here:
Unable to Install and configure the MDX transformer plugin (and dependencies) in gatsby site
(1 answer)
Closed 24 days ago.
I'm getting the following errors while using the command npm install.
I'm new to gatsby and react don't know how resolve.
pegasus#pegasus:~/Documents/MyWebsite/blog-main$ npm install
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: gatsby-plugin-mdx#5.5.0
npm ERR! Found: #mdx-js/react#1.6.22
npm ERR! node_modules/#mdx-js/react
npm ERR! #mdx-js/react#"^1.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer #mdx-js/react#"^2.0.0" from gatsby-plugin-mdx#5.5.0
npm ERR! node_modules/gatsby-plugin-mdx
npm ERR! dev gatsby-plugin-mdx#"^5.5.0" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: #mdx-js/react#2.2.1
npm ERR! node_modules/#mdx-js/react
npm ERR! peer #mdx-js/react#"^2.0.0" from gatsby-plugin-mdx#5.5.0
npm ERR! node_modules/gatsby-plugin-mdx
npm ERR! dev gatsby-plugin-mdx#"^5.5.0" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR!
npm ERR! For a full report see:
npm ERR! /home/pegasus/.npm/_logs/2023-01-27T07_02_53_230Z-eresolve-report.txt
Seems, version compatibility issue, You have few options to resolve this issue:
Upgrade the version of #mdx-js/react package: You can try to upgrade the version of #mdx-js/react package in your project to a version that is compatible with gatsby-plugin-mdx by running the command npm install #mdx-js/react#2.x.x
Downgrade the version of gatsby-plugin-mdx package: You can try to downgrade the version of gatsby-plugin-mdx package in your project to a version that is compatible with the current version of #mdx-js/react package by running the command npm install gatsby-plugin-mdx#x.x.x.
Use --force or --legacy-peer-deps: You can also use npm install --force or npm install --legacy-peer-deps to ignore the peer dependency conflict and install the packages, but this option can lead to unexpected behavior and it's not recommended.
use npm install --legacy-peer-deps

How should I resolve this Angular node package module dependency conflict?

I just updated all my node modules using npm-check-updates.
I did this so I could install the latest version ngx-stripe, which needed some updated node modules that I didn't have installed.
After updating all my node modules and then trying to install ngx-stripe I got this error below, showing me that ngx-gallery-9#1.0.6 has a peer dependency of tslib 1.10.0, which is true, but my installed version is tslib 2.5.0 in node modules.
QUESTION - Should I use --force or --legacy-peer-deps when running the npm install for ngx-stripe or is there something else I should try first like updating the tslib peer dependency for ngx-gallery-9?
Here is what I see:
➜ client git:(master) ✗ npm install ngx-stripe #stripe/stripe-js
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: ngx-gallery-9#1.0.6
npm ERR! Found: tslib#2.5.0
npm ERR! node_modules/tslib
npm ERR! tslib#"^2.3.0" from #angular/animations#15.1.2
npm ERR! node_modules/#angular/animations
npm ERR! peerOptional #angular/animations#"15.1.2" from #angular/platform-browser#15.1.2
npm ERR! node_modules/#angular/platform-browser
npm ERR! peer #angular/platform-browser#"15.1.2" from #angular/forms#15.1.2
npm ERR! node_modules/#angular/forms
npm ERR! peer #angular/forms#"^11.2.11 || ^12.0.4 || ^13.0.0 || ^14.0.0 || ^15.0.0" from #zxing/ngx-scanner#3.8.0
npm ERR! node_modules/#zxing/ngx-scanner
npm ERR! 2 more (ngx-bootstrap, the root project)
npm ERR! 3 more (#angular/platform-browser-dynamic, #angular/router, the root project)
npm ERR! peer #angular/animations#"^15.0.0" from ngx-bootstrap#10.2.0
npm ERR! node_modules/ngx-bootstrap
npm ERR! ngx-bootstrap#"^10.2.0" from the root project
npm ERR! 1 more (the root project)
npm ERR! tslib#"^2.3.0" from #angular/common#15.1.2
npm ERR! node_modules/#angular/common
npm ERR! peer #angular/common#"15.1.2" from #angular/forms#15.1.2
npm ERR! node_modules/#angular/forms
npm ERR! peer #angular/forms#"^11.2.11 || ^12.0.4 || ^13.0.0 || ^14.0.0 || ^15.0.0" from #zxing/ngx-scanner#3.8.0
npm ERR! node_modules/#zxing/ngx-scanner
npm ERR! #zxing/ngx-scanner#"^3.8.0" from the root project
npm ERR! 2 more (ngx-bootstrap, the root project)
npm ERR! peer #angular/common#"^15.0.0 || ^16.0.0" from #angular/google-maps#15.1.2
npm ERR! node_modules/#angular/google-maps
npm ERR! #angular/google-maps#"^15.1.2" from the root project
npm ERR! 10 more (#angular/platform-browser, ...)
npm ERR! 20 more (#angular/compiler, #angular/compiler-cli, ...)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer tslib#"^1.10.0" from ngx-gallery-9#1.0.6
npm ERR! node_modules/ngx-gallery-9
npm ERR! ngx-gallery-9#"^1.0.6" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: tslib#1.14.1
npm ERR! node_modules/tslib
npm ERR! peer tslib#"^1.10.0" from ngx-gallery-9#1.0.6
npm ERR! node_modules/ngx-gallery-9
npm ERR! ngx-gallery-9#"^1.0.6" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR!
npm ERR! For a full report see:
npm ERR! /Users/charles/.npm/_logs/2023-01-27T08_58_58_320Z-eresolve-report.txt
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/charles/.npm/_logs/2023-01-27T08_58_58_320Z-debug-0.log
➜ client git:(master) ✗
Your problem is completely unrelated to ngx-stripe, but whenever you run npm install, NPM tries to fix all of its dependencies in package.json at the same time, and because you have a problem with ngx-gallery-9, all npm installs are failing. You can ignore the error for now, using --legacy-peer-deps, which will tell NPM to not try to deal with peer dependencies and just let you install the thing you want to install (ngx-stripe).
With regards to fixing the error itself, there's not much you can do here. ngx-gallery-9 is using an older version of tslib, and hasn't been updated for a long time. There's currently an open bug requesting that the library maintainer update his packages.
More specifically,
Angular 15 requires tslib#"^2.3.0", but ngx-gallery-9 requires tslib#"^1.10.0". You can try forcing it to use the latest version by using --legacy-peer-deps during ALL your future npm installations, as well as running npm install tslib#^2.3.0 --save --legacy-peer-deps to manually choose to use the newer version, which will force the whole project to use tslib#"^2.3.0" and ignore ngx-gallery-9's complaints, but there's a strong possibility that ngx-gallery-9 won't work as expected.
Your best bet is to either
use a different gallery than ngx-gallery-9, or
Simply ignore the problem. Force everything to use tslib#"^2.3.0" with npm install tslib#^2.3.0 --save --legacy-peer-deps and hope ngx-gallery-9 won't have any errors, or
downgrade Angular to an earlier version (Which is very messy, and not really recommended unless you didn't intend to be using Angular 15).
Edit:
Or instead undo all the changes that npm-check-updates did, and instead just install an older version of ngx-stripe that's compatible with all of your packages. ngx-stripe has a chart showing which version to use depending on your version of Angular, here: https://www.npmjs.com/package/ngx-stripe
Just type:
npm install ngx-stripe #stripe/stripe-js --force
or npm install ngx-stripe #stripe/stripe-js--legacy-peer-deps

Error while running npm install #material-ui/core in VSCode in windows

PS C:\Users\misss\tnodejs_ec> npm install #material-ui/core
npm WARN config global --global, --local are deprecated. Use --location=global instead.
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: tnodejs_ec#0.1.0
npm ERR! Found: react#18.2.0
npm ERR! node_modules/react
npm ERR! react#"18.2.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react#"^16.8.0 || ^17.0.0" from #material-ui/core#4.12.4
npm ERR! node_modules/#material-ui/core
npm ERR! #material-ui/core#"*" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See C:\Users\misss\AppData\Local\npm-cache\eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\misss\AppData\Local\npm-cache_logs\2022-07-04T09_27_24_111Z-debug-0.log
PS C:\Users\misss\tnodejs_ec>
If you really want to install material UI then use force to npm no matter what happen you have to install this forcefully.
npm install #material-ui/core --force
MUI doesn't work with React18, its because of an issue in previous release of MUI, now its been fixed in the latest version.
If you want to stick to #material-ui/core#4.12.4 then your best bet is to include the --legacy-peer-deps option. I got it working after adding this option like
npm install #material-ui/core --legacy-peer-deps
However, the best way forward is to update to the latest MUI version. Current version of MUI is v5.10.1
PS: with recent updates the name of the package in NPM registry has been updated too
old: #material-ui/core
new: #mui/material
Don't forget to update your package.json

How to clear the error while installing #ngrx/store?

This is the error I'm getting while installing #ngrx/store. Can anyone help to resolve this error
PS C:\Users\Welcome\ngrx-test> npm install #ngrx/store
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: ngrx-test#0.0.0
npm ERR! Found: #angular/core#11.0.8
npm ERR! node_modules/#angular/core
npm ERR! #angular/core#"~11.0.1" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer #angular/core#"^10.0.0" from #ngrx/store#10.1.2
npm ERR! node_modules/#ngrx/store
npm ERR! #ngrx/store#"*" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See C:\Users\Welcome\AppData\Local\npm-cache\eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Welcome\AppData\Local\npm-cache\_logs\2021-01-12T15_07_10_434Z-debug.log
Here are the possible solutions you can try:
Deleting Node Modules and Cache
npm v5 and above:
npx rimraf ./**/node_modules
npm cache clear --force
npm install #ngrx/store
npm v4 or below:
npm install rimraf -g
rimraf .\**\node_modules
npm cache clear --force
npm install #ngrx/store
Legacy Peer Dependencies
Try to install with the legacy peer dependencies option which will ignore peerDependencies while installing.
npm install #ngrx/store --legacy-peer-deps
Force
If that doesn't work, then try the force option.
npm install #ngrx/store --force
Different Version of #ngrx/store
If none of the options above work, you can try installing a different version of #ngrx/store.
npm install #ngrx/store#10.0.0
Different version of node & npm
Finally, as a last resort, you can try downgrading or upgrading your node and npm versions.
Here are instructions on how to do so.
Hope this helped!

How do I fix this NPM dependency issue for react-native-spotify-remote

I'm having trouble figuring out how to resolve a dependency related issue I'm having. I'm trying to install the npm module react-native-spotify-remote within a fresh React Native project and I am getting the following error:
$ npx react-native init test && cd test
$ npm i --save react-native-spotify-remote
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: test#0.0.1
npm ERR! Found: react-native#0.63.3
npm ERR! node_modules/react-native
npm ERR! react-native#"0.63.3" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react-native#"^0.61.5" from react-native-spotify-remote#0.3.2
npm ERR! node_modules/react-native-spotify-remote
npm ERR! react-native-spotify-remote#"*" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See C:\Users\xxx\AppData\Local\npm-cache\eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\xxx\AppData\Local\npm-cache\_logs\2020-11-15T13_40_38_674Z-debug.log
As I read this error, it seems to me that it is saying that react-native-spotify-remote has a dependency of react-native at version 0.61.5 or higher, and version 0.63.3 is installed. Does that not mean the dependency is satisfied? I know that by downgrading react-native to an earlier version, as used in their example app, I could probably resolve this issue, but I want to try understand why this won't work first and I would ideally like to use the latest version.
Using the --force or --legacy-peer-deps flags does not solve the issue either.
I've also opened an issue on the GitHub repo but no luck there so far either.
Looks like it’s a problem with Peer Dependencies with npm, try:
npm install --legacy-peer-deps

Resources