Home > Net >  Problem in Installing Material ui with next js (with and without typescript) error
Problem in Installing Material ui with next js (with and without typescript) error

Time:04-02

im new to react and next js so sorry for my idiotic question, im trying to install material ui in a new next js app (i used "npx create-next-app@latest"), and im using the Material ui docs and the ts section (https://mui.com/guides/typescript/#main-content)

i got the following error in cli / terminal:

npm install @mui/material @emotion/react @emotion/styled
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR!   peer react@">=16.8.0" from @emotion/[email protected]      
npm ERR!   node_modules/@emotion/react
npm ERR!     @emotion/react@"*" from the root project
npm ERR!     peerOptional @emotion/react@"^11.5.0" from @mui/[email protected]
npm ERR!     node_modules/@mui/material
npm ERR!       @mui/material@"*" from the root project
npm ERR!     1 more (@emotion/styled)
npm ERR!   1 more (@emotion/styled)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^17.0.0" from @mui/[email protected]
npm ERR! node_modules/@mui/material
npm ERR!   @mui/material@"*" 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!

i have tried to use the material ui component and got a compiler error, even though i have tried in a nextjs (without ts and with) and with the flags: --force, or --legacy-peer-deps

please help! a lot of thanks in advance! i just need to start my project!

install material ui in next-js with and without typescript

CodePudding user response:

If I had this problem I would have deleted package.json and installed it again and after that I try to install Material. Did you try this?

  • Related