Conflicting Packages in React Project

Viewed 210

Just looking to resolve this. I'm quite sure it'll be an easy solve for people used to node packaging errors.

I'm trying to resolve: npm install @material-ui/icons

When using, I receive the following:


npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: @mui/material@5.2.3
npm ERR! Found: react@16.14.0
npm ERR! node_modules/react
npm ERR!   react@"^16.13.0" from the root project
npm ERR!   peer react@">=16.8.0" from @emotion/react@11.7.0
npm ERR!   node_modules/@emotion/react
npm ERR!     peer @emotion/react@"^11.0.0-rc.0" from @emotion/styled@11.6.0
npm ERR!     node_modules/@emotion/styled
npm ERR!       peerOptional @emotion/styled@"^11.3.0" from @mui/material@5.2.3
npm ERR!       node_modules/@mui/material
npm ERR!         @mui/material@"^5.2.3" from the root project
npm ERR!       3 more (@mui/styled-engine, @mui/system, the root project)
npm ERR!     peerOptional @emotion/react@"^11.5.0" from @mui/material@5.2.3
npm ERR!     node_modules/@mui/material
npm ERR!       @mui/material@"^5.2.3" from the root project
npm ERR!     3 more (@mui/styled-engine, @mui/system, the root project)
npm ERR!   11 more (@emotion/styled, @testing-library/react, ...)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^17.0.2" from @mui/material@5.2.3
npm ERR! node_modules/@mui/material
npm ERR!   @mui/material@"^5.2.3" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: react@17.0.2
npm ERR! node_modules/react
npm ERR!   peer react@"^17.0.2" from @mui/material@5.2.3
npm ERR!   node_modules/@mui/material
npm ERR!     @mui/material@"^5.2.3" 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\Nathan\AppData\Local\npm-cache\eresolve-report.txt for a full report.

I've worked back to my yarn.lock package, which has the following. One note, I am not using yarn.


"react@*", "react@^17.0.2", "react@>= 16", "react@>= 16.8.0", "react@>=16.6.0", "react@>=16.8.0", "react@17.0.2":
"integrity" "sha512-gnhPt75i/dq/z3/6q/0asP78D0u592D5L1pd7M8P+dck6Fu/jJeL6iVVK23fptSUZj8Vjf++7wXA8UNclGQcbA=="
"resolved" "https://registry.npmjs.org/react/-/react-17.0.2.tgz"
"version" "17.0.2"
dependencies:
    "loose-envify" "^1.1.0"
    "object-assign" "^4.1.1"

It's likely also worth noting my package.json is:


{
"name": "new",
"version": "0.1.0",
"private": true,
"dependencies": {
    "@emotion/react": "^11.7.0",
    "@emotion/styled": "^11.6.0",
    "@fontsource/roboto": "^4.5.1",
    "@mui/material": "^5.2.3",
    "@testing-library/jest-dom": "^5.11.4",
    "@testing-library/react": "^11.1.0",
    "@testing-library/user-event": "^12.1.10",
    "react": "^16.13.0",
    "react-dom": "^16.13.0",
    "react-scripts": "4.0.3",
    "styled-components": "^5.3.3",
    "web-vitals": "^1.0.1"
},
"scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
},
"eslintConfig": {
    "extends": [
    "react-app",
    "react-app/jest"
    ]
},
"browserslist": {
    "production": [
    ">0.2%",
    "not dead",
    "not op_mini all"
    ],
    "development": [
    "last 1 chrome version",
    "last 1 firefox version",
    "last 1 safari version"
    ]
}
}

0 Answers
Related