'NPM Dependency Resolution Conflicts
When I run node install
I get the following output:
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/react
npm ERR! react@"^18.1.0" from the root project
npm ERR! peer react@">=16.3" from @deck.gl/[email protected]
npm ERR! node_modules/@deck.gl/react
npm ERR! @deck.gl/react@"8.7.8" from [email protected]
npm ERR! node_modules/deck.gl
npm ERR! deck.gl@"^8.7.8" from the root project
npm ERR! 15 more (@emotion/react, @emotion/styled, @mui/base, ...)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.0.0 || ^17.0.0" from [email protected]
npm ERR! node_modules/google-map-react
npm ERR! google-map-react@"^2.1.10" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: [email protected]
npm ERR! node_modules/react
npm ERR! peer react@"^16.0.0 || ^17.0.0" from [email protected]
npm ERR! node_modules/google-map-react
npm ERR! google-map-react@"^2.1.10" 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.
and here is my package.json
file:
{
"name": "frontend",
"version": "0.1.0",
"private": true,
"dependencies": {
"@emotion/react": "^11.9.0",
"@emotion/styled": "^11.8.1",
"@mui/icons-material": "^5.6.2",
"@mui/material": "^5.6.3",
"deck.gl": "^8.7.8",
"react": "^18.1.0",
"react-dom": "^18.1.0",
"react-router": "^6.3.0",
"react-router-dom": "^5.1.2",
"react-scripts": "5.0.1",
"react-transition-group": "^4.3.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
I have tried already npm install --legacy-peer-deps
and npm install --force
none of which changed the error message. I also tried npm install --legacy-peer-deps --save google-maps-react
to see if I had to perform this individually for each package, no luck. I am aware that this error is relatively common, and it has something to do with the npm version and the dreaded breaking changes.
Does anyone know any other steps I can take?
Solution 1:[1]
I resolved the issue by running npm install --legacy-peer-deps
after going from my pc's version of node 18.0.0 to the latest 16 LTS.
Solution 2:[2]
Found: [email protected] npm ERR! peer react@"^16.8.0 || ^17.0.0"
- npm config set legacy-peer-deps true
- npm install --save --legacy-peer-deps
- npm install --force
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Nick the Community Scientist |
Solution 2 | Manuetov |