I am getting an error trying to install the react-redux package onto my create-react-app application. I have tried deleting and reinstalling my node_modules folder as well as installing it with admin permissions and I am still receiving the same error
➜ frontend git:(main) ✗ npm i react-redux
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
Here is the remaining output from the console
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/react
npm ERR! react@"^17.0.1" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.8.3" from [email protected]
npm ERR! node_modules/react-redux
npm ERR! react-redux@"*" 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.
Here is the list of current dependencies in my package.json
"dependencies": {
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.5.0",
"@testing-library/user-event": "^7.2.1",
"axios": "^0.21.0",
"react": "^17.0.1",
"react-bootstrap": "^1.4.0",
"react-dom": "^17.0.1",
"react-router-bootstrap": "^0.25.0",
"react-router-dom": "^5.2.0",
"react-scripts": "3.4.4",
"redux": "^4.0.5",
"redux-devtools-extension": "^2.13.8",
"redux-thunk": "^2.3.0",
"tachyons": "^4.12.0"
},
Solution 1: Ignore the peerDependencies The easiest way to fix the issue is to pass an additional parameter –legacy-peer-deps to npm install. The --legacy-peer-deps tells the npm to ignore the peer dependencies and continue the installation of the package.
To install the full React toolchain on WSL, we recommend using create-react-app: Open a terminal(Windows Command Prompt or PowerShell). Create a new project folder: mkdir ReactProjects and enter that directory: cd ReactProjects . npx is the package runner used by npm to execute packages in place of a global install.
It looks like you are using the latest npm version (v7).
As mention in the logs, try with
npm install --legacy-peer-deps
The last time npm Blog mentioned the --legacy-peer-deps
flag was while their beta version of npm v7 got public. To read more about the flag go here.
Try installing recommended nodejs version(screen shot below). Which should fix this issue.
Here is a recreation of this error and its solution (screenshots below):
Problem:
Nodejs : Latest features:
Solution:
Nodejs : Recommended for most users:
Installing the Recommended version of node js fixed this issue instantly allowing installation of relevant dependancies.
Incase you are facing this issue with a react-native dependency then once you have installed the recommended version be sure to update your pod file.
Two ways:
npm install <package-name> --legacy-peer-deps
The better way is to install the recommended version of node to work for all packages.
Try using Node.js latest "Recommended For Most Users" Version . it worked for me
I had this issue and nothing seemed to work.
I fixed it by downgrading node to version 12.14.1
Uninstall the current node version and install 12.14.1 from this link
Tried for Mac, it worked.. follow the steps for upgrading to the latest LTS
Before updating the Node.js release, check which version you are currently using with: node -v
Next, clear npm cache with the command: npm cache clean -f
Install n globally: npm install -g n
Now that you have n installed, you can use the module to install the latest stable release of Node.js: sudo n stable
Alternatively, you can install the Node.js release with the latest features:
sudo n latest
Or, install a specific version number with: n [version.number]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With