Screenshot of Error is in this Picture
node -v v16.17.0
npm -v 8.15.0
react version 18.2.0
Can any one resolve this problem?
CodePudding user response:
as answered it is a version conflict but still, you can install any packages just add --force to the end of every command.
before:
npm i @material-ui/icons
after:
npm i @material-ui/icons --force
Hope this solution help!
CodePudding user response:
I guess you fetched node_modules a long time ago.
material-ui/core@ is deprecated , therefore you cant use that package for now.
best thing you can do tho, go to your package.json file and delete dependency lines with core@ and icons@, also delete your node_modules and ran npm install command in your terminal, after that, you can also install icons@ package.
CodePudding user response:
install the package and use --force in last for example npm i --force eg npm i @material-ui/icons --force
CodePudding user response:
Hi @aakash,
As you can see in the above image. There is a conflict
with the version of React
And you want to install @material-ui/icons
package. But, The things are, @material-ui/icons
requires a version of React that is compatible with @material-ui/icons
package. The version you are using now is 18.2.0
. So, you could just install 16.8.0
or 17.0.0
. For resolve that issue.
Here is an example. How you can be downgrading the version of React.
npm install react@^16.8.0
ornpm install react@^17.0.0
.
Alternatively, you could do that method. Which I not recommend. To update the version of @material-ui/core
which is compatible with your React
version.
For example:-
npm install @material-ui/core@^5.0.0
.
Also, The another option would be to use --legacy-peer-deps
flag. It's useful when you are trying to install a package that has peer dependencies
that are not compatible
with the current versions
of those dependencies.
npm install @material-ui/icons --legacy-peer-deps
Note:- It may be a better solution to resolve the dependency conflict by updating
or downgrading
the versions of the packages involved, as I suggested earlier, rather than using the --legacy-peer-deps
flag.