I cannot install #material-ui/core or #mui/styles My React and MUI versions are
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "5.0.1",
"#mui/icons-material": "^5.10.9",
"#mui/material": "^5.10.10",
"#emotion/react": "^11.10.4",
"#emotion/styled": "^11.10.4",
When I try to use makeStyles it says I need to install #mui/styles but when I try to install it it gives the following error
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: my-app#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!
Where am I missing out? I cannot find out the problem.
As noted in https://mui.com/styles/basics/, #mui/styles is the Material UI v4 legacy styling solution. There's no guarantee of compatibility with React 18.
If you'd like to continue using #mui/styles, the recommendation from the MUI team is to stay on React 17.
Full conversation can be found here: https://github.com/mui/material-ui/issues/32142
The #material-ui/core library is from major version 4 (as you can see via the error snippet, from #material-ui/core#4.12.4), compared to those that begin with #mui/... which belong to major version 5. Material UI v4 only supports up to React 17 (as you can see via the error snippet, peer react#"^16.8.0 || ^17.0.0").
Since you are using React 18, you have to install v5 and not v4. #mui/styles is v5, so there is another library in your dependencies that is asking for #material-ui/core v4 or you accidentally added the wrong library at some point. Check that every Material dependency in your project begins with "#mui" and not "#material-ui"
Related
I'm following an e-commerce tutorial, cannot install all the packages react-paypal button in npm with react 18
npm i react-paypal-smart-button
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
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\a\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\a\AppData\Local\npm-cache\_logs\2023-02-09T15_12_52_013Z-debug-0.log
react-paypal-smart-button has peerDeps like that:
"peerDependencies": {
"prop-types": "^15.6.0",
"react": "^17.0.2",
"react-dom": "^17.0.2"
},
And you installed react version 18.
So just use flag npm i--legacy-peer-deps to ignore that warning. (then react-paypal-smart-button will use your react 18 instead of recommended 17. Hope that will not break the package:))
About peerDeps - https://nodejs.org/es/blog/npm/peer-dependencies/
Long story short, I currently have React 16 installed and I wanted to add React 17 to check tests, migrate, etc.
Running npm install throws an error, because react-dom#17 requires react#17 and it seems to not being able to find one.
The question is - is there a way to fix this problem without using --force or --legacy-peer-deps flags?
I created aliased packages, using react-redux as an example.
"react": "^16.8.6",
"react-17": "npm:react#^17",
"react-dom": "^16.8.6",
"react-dom-17": "npm:react-dom#^17"
Running npm install throws an error, because react-dom#17 requires react#17 and it seems to not being able to find one.
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: platform-modules#0.0.0
npm ERR! Found: react#16.14.0
npm ERR! node_modules/react
npm ERR! dev react#"^16.8.6" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react#"npm:react#^17" from react-dom-17#17.0.2
npm ERR! node_modules/react-dom-17
npm ERR! dev react-dom-17#"npm:react-dom#^17" from the root project
I tried using npm overrides, as well as peerDependenciesMeta but it unfortunately didn't help.
"overrides": {
"react-dom-17": {
"react": "$react-17"
}
},
"peerDependenciesMeta": {
"react-dom": {
"optional": true
}
}
react-redux package uses this approach, but it uses Yarn instead of NPM.
I have a react app created with cra. I want to install webpack in order to setup module federation.
I am getting this error on running the below command:
$ npm i --D webpack#5.24.0 webpack-cli webpack-server html-webpack-plugin babel-loader webpack-dev-server
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: netlify-foot#0.1.0
npm ERR! Found: react#17.0.2
npm ERR! node_modules/react
npm ERR! react#"^17.0.2" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react#"~0.9" from webpack-server#0.1.2
npm ERR! node_modules/webpack-server
npm ERR! dev webpack-server#"*" 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:\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:\AppData\Local\npm-cache\_logs\2021-06-05T15_25_05_470Z-debug.log
package.json
{
"dependencies": {
"#testing-library/jest-dom": "^5.12.0",
"#testing-library/react": "^11.2.7",
"#testing-library/user-event": "^12.8.3",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "4.0.3",
"web-vitals": "^1.1.2"
}
}
What is the issue? How to get this working?
Your install command is:
npm i --D webpack#5.24.0 webpack-cli webpack-server html-webpack-plugin babel-loader webpack-dev-server
This means, it tries to add the following six packages:
webpack#5.24.0
webpack-cli
webpack-server
html-webpack-plugin
babel-loader
webpack-dev-server
But webpack-server is not a thing. Remove it.
If you look closely at your error message, it kinda tries to tell you the same thing:
npm ERR! Could not resolve dependency:
npm ERR! peer react#"~0.9" from webpack-server#0.1.2
It says that it fails to satisfy dependencies caused by this webpack-server. Make sure to get rid of it. That will at least fix this problem.
Your next problem
NOTE however, that for further customization of CRA's webpack build, given you don't want to eject, you also need a way to override it's default build settings.
For that, you might want to check out CRACO.
CRACO (like Webpack Module Federation) does not have very good documentation, but it has a few webpack-related examples here.
This question already has answers here:
What does npm install --legacy-peer-deps do exactly? When is it recommended / What's a potential use case?
(7 answers)
Closed 1 year ago.
I am getting the following error while updating from React 17.0.1 to 17.0.2.
It's not entirely clear to me why the dependencies are causing problems.
I'm using npm v 7.4.
It seems that some dependencies are incompatible with react 17. Do I understand correctly?
But npm shows e. g.
npm ERR! peer react-dom#"^15.0.0 || ^16.0.0 || ^17.0.0" from react-calendly#2.0.0
npm ERR! node_modules/react-calendly
If I think correct, React 17 should work.
Could someone explain the problem to me briefly? Is there a solution for this?
Error:
npm install --save react#17.0.2
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! Found: react#17.0.2
npm ERR! node_modules/react
npm ERR! react#"17.0.2" from the root project
npm ERR! peer react#"^0.14.0 || ^15.0.0 || ^16.0.0 || ^17.0.0" from mini-create-react-context#0.4.1
npm ERR! node_modules/mini-create-react-context
npm ERR! mini-create-react-context#"^0.4.0" from react-router#5.2.0
npm ERR! node_modules/react-router
npm ERR! react-router#"5.2.0" from react-router-dom#5.2.0
npm ERR! node_modules/react-router-dom
npm ERR! react-router-dom#"^5.2.0" from the root project
npm ERR! 7 more (react-calendly, react-icons, react-router, ...)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react#"17.0.1" from react-dom#17.0.1
npm ERR! node_modules/react-dom
npm ERR! peer react-dom#"^15.0.0 || ^16.0.0 || ^17.0.0" from react-calendly#2.0.0
npm ERR! node_modules/react-calendly
npm ERR! react-calendly#"^2.0.0" from the root project
npm ERR! peer react-dom#"^15.5.4 || ^16.0.0 || ^17.0.0" from react-scroll#1.8.2
npm ERR! node_modules/react-scroll
npm ERR! react-scroll#"^1.8.2" from the root project
npm ERR! 2 more (styled-components, 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!
My dependencies:
"emailjs-com": "^2.6.4",
"react": "^17.0.1",
"react-calendly": "^2.0.0",
"react-dom": "^17.0.1",
"react-icons": "^4.2.0",
"react-router-dom": "^5.2.0",
"react-router-scroll-top": "^0.2.1",
"react-scripts": "^4.0.3",
"react-scroll": "^1.8.2",
"styled-components": "^5.3.0",
"swiper": "^6.5.0"
I don't understand, why 17.0.0 should be working, but 17.0.2 not.
Thanks for your help.
You have dependency conflict which will create this problem.
I suggest solve using --force or --legacy-peer-deps.
So try :
npm install --save react#17.0.2 --force
OR
npm install --save react#17.0.2 --legacy-peer-deps
Reason of problem :
There is dependency conflict which means dependency not compatible with other or something similar which will create this problem.
I am trying to install the library #material-ui/pickers by running:
npm i #material-ui/pickers
But this error shows up:
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: five#0.1.0
npm ERR! Found: react#17.0.1
npm ERR! node_modules/react
npm ERR! react#"^17.0.1" from the root project
npm ERR! peer react#"^16.8.0 || ^17.0.0" from #material-ui/core#4.11.3
npm ERR! node_modules/#material-ui/core
npm ERR! #material-ui/core#"^4.11.3" from the root project
npm ERR! peer #material-ui/core#"^4.0.0" from #material-ui/pickers#3.2.10
npm ERR! node_modules/#material-ui/pickers
npm ERR! #material-ui/pickers#"*" from the root project
npm ERR! 1 more (react-dom)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react#"^16.8.4" from #material-ui/pickers#3.2.10
npm ERR! node_modules/#material-ui/pickers
npm ERR! #material-ui/pickers#"*" 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.
Here are my package.json dependencies:
"dependencies": {
"#material-ui/core": "^4.11.3",
"#testing-library/jest-dom": "^5.11.9",
"#testing-library/react": "^11.2.3",
"#testing-library/user-event": "^12.6.2",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-scripts": "4.0.1",
"web-vitals": "^0.2.4"
},
I thought there was maybe some problems in other parts of my file, so I started a create-react-app from scratch and tried again, but the same error is still occuring.
Perhaps you want to check out the new Material UI DatePicker from over here. If I understood correctly#material-ui/pickers isn't used anymore.
#material-ui/pickers required react to be 16.13.1 or higher but not to 17.xx.xx. Right now you are using React version 17.0.1. You can try to downgrade the React to version 16 and see if it works
I even had this error and what I did was simply closed my VScode because the project was open in it and again tried to install the package and guess what it works. You can try this solution hopefully it works.