GabrielJSW
GabrielJSW

Reputation: 244

Could not resolve dependency

I have been trying to download a template to start customizing it. Upon downloading it, one is supposed to install all local dependencies using npm install or yarn install. I have done both of those and I have gotten the same error both times. Moreover I have tried using the same command with --force and --legacy-peer-deps, as advised in the error message. I found a GitHub issue discussing this precise problem and some other stack overflow threads. I have tried everything I have come across, and it is just not working. Moreover I have installed the recommended version of node, so that is not the problem either, as suggested in a different thread.

The error message can be seen below.

While resolving: @mui/[email protected]
npm ERR! Found: @emotion/[email protected]
npm ERR! node_modules/@emotion/react
npm ERR!   @emotion/react@"11.4.1" from the root project
npm ERR!   peer @emotion/react@"^11.0.0-rc.0" from @emotion/[email protected]
npm ERR!   node_modules/@emotion/styled
npm ERR!     @emotion/styled@"11.3.0" from the root project
npm ERR!     peerOptional @emotion/styled@"^11.3.0" from @mui/[email protected]
npm ERR!     node_modules/@mui/material
npm ERR!       @mui/material@"5.2.0" from the root project
npm ERR!       1 more (@mui/icons-material)
npm ERR!     1 more (@mui/styled-engine)
npm ERR!   1 more (@mui/styled-engine)
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peerOptional @emotion/react@"^11.5.0" from @mui/[email protected]
npm ERR! node_modules/@mui/material
npm ERR!   @mui/material@"5.2.0" from the root project
npm ERR!   peer @mui/material@"^5.0.0" from @mui/[email protected]
npm ERR!   node_modules/@mui/icons-material
npm ERR!     @mui/icons-material@"5.2.0" from the root project
npm ERR! 
npm ERR! Conflicting peer dependency: @emotion/[email protected]
npm ERR! node_modules/@emotion/react
npm ERR!   peerOptional @emotion/react@"^11.5.0" from @mui/[email protected]
npm ERR!   node_modules/@mui/material
npm ERR!     @mui/material@"5.2.0" from the root project
npm ERR!     peer @mui/material@"^5.0.0" from @mui/[email protected]
npm ERR!     node_modules/@mui/icons-material
npm ERR!       @mui/icons-material@"5.2.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.

The template: https://www.creative-tim.com/product/material-dashboard-react?ref=readme-mdr#

GitHub issue: https://github.com/creativetimofficial/material-dashboard-react/issues/171

Thanks in advance.

Upvotes: 2

Views: 9091

Answers (3)

Chris R
Chris R

Reputation: 29

I received this error while not in the folder of my react app. Cd into it and should be good but I am positive you found this answer by now or stumbled upon it like me. Best wishes

Upvotes: 0

Vishal J
Vishal J

Reputation: 61

upgrade your version from package.json file and run again "npm install" command

Upvotes: 0

GabrielJSW
GabrielJSW

Reputation: 244

The problem is that the specific version of @emotion/react used in the template, is not working anymore.

To solve the problem I went to the package.json and changed the version from 11.4.1 to 11.5.0 manually. Seems that the 11.5.0 solves the problem with the template used.

Upvotes: 4

Related Questions