redux-toolkit: @reduxjs/toolkit doesn't sit well with react-redux 9.0.0+
No matter the version of @reduxjs/toolkit (in my case, either 2.0.1. or 1.9.7), I can’t install the new react-redux.
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: next-app@undefined
npm ERR! Found: react-redux@8.1.3
npm ERR! node_modules/react-redux
npm ERR! react-redux@"^9.0.0" from the root project
npm ERR! peerOptional react-redux@"^7.2.1 || ^8.1.3 || ^9.0.0" from @reduxjs/toolkit@2.0.1
npm ERR! node_modules/@reduxjs/toolkit
npm ERR! @reduxjs/toolkit@"^2.0.1" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! react-redux@"^9.0.0" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: redux@5.0.0
npm ERR! node_modules/redux
npm ERR! peerOptional redux@"^5.0.0" from react-redux@9.0.2
npm ERR! node_modules/react-redux
npm ERR! react-redux@"^9.0.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.
npm ERR!
npm ERR!
npm ERR! For a full report see:
npm ERR! /Users/vince/.npm/_logs/2023-12-06T23_10_06_622Z-eresolve-report.txt
npm ERR! A complete log of this run can be found in: /Users/vince/.npm/_logs/2023-12-06T23_10_06_622Z-debug-0.log
About this issue
- Original URL
- State: closed
- Created 7 months ago
- Reactions: 1
- Comments: 32 (5 by maintainers)
Yeah, that’s the other problem here.
I just published React-Redux 9.0.3, which lowers the React types dep. But, it still needs to be at least 18.2.25. Please try updating your project to at least that version, and preferably the latest 18.2.41.
in your
package.json
:I uninstalled redux-logger but it made no difference.
it works on the new project. however on my existing project, it still errors out. See my package.json
I added
“@types/node”: “20.3.1”, “@types/react”: “^18.2.41”, “@types/react-dom”: “^18.2.17”, “@types/redux-logger”: “3.0.9”, “redux-logger”: “3.0.6”
Then ran
After that, I attempted to install:
But still got
It looks like the actual problem here is that the Next project defaults to listing:
React-Redux as currently published wants newer versions:
If i update the Next app’s
package.json
to list those same newer React types versions, before trying to upgrade React-Redux and Redux Toolkit, it installs fine:So, try that?
That’s my suspicion. Perhaps we should wait for a newer version that is compatible with @redux/toolkit?
npm version: 9.8.1 node version: v18.18.2
I tried it on both my existing app and a new one.
I just started a new project to prove this is an issue:
npx create-next-app --example with-redux nextjs_redux_new
The dependencies:
Then when I installed the newest version of react-redux, it still fails. Even after upgrading reduxjs/toolkit
I have the same problem. Installing
npm install @reduxjs/toolkit react-redux
from the quick start guide gives me the following error:npm ERR! code ERESOLVE npm ERR! ERESOLVE could not resolve npm ERR! npm ERR! While resolving: react-redux@9.0.2 npm ERR! Found: @types/react@18.2.33 npm ERR! node_modules/@types/react npm ERR! dev @types/react@“18.2.33” from the root project npm ERR! @types/react@“*” from @types/react-dom@18.2.14 npm ERR! node_modules/@types/react-dom npm ERR! dev @types/react-dom@“18.2.14” from the root project npm ERR! @types/react-dom@“^18.0.0” from @testing-library/react@14.0.0 npm ERR! node_modules/@testing-library/react npm ERR! dev @testing-library/react@“^14.0.0” from the root project npm ERR! 1 more (zustand) npm ERR! npm ERR! Could not resolve dependency: npm ERR! peerOptional @types/react@“^18.2.41” from react-redux@9.0.2 npm ERR! node_modules/react-redux npm ERR! react-redux@“^9.0.0” from the root project npm ERR! peerOptional react-redux@“^7.2.1 || ^8.1.3 || ^9.0.0” from @reduxjs/toolkit@2.0.1 npm ERR! node_modules/@reduxjs/toolkit npm ERR! @reduxjs/toolkit@“^2.0.0” from the root project npm ERR! npm ERR! Conflicting peer dependency: @types/react@18.2.42 npm ERR! node_modules/@types/react npm ERR! peerOptional @types/react@“^18.2.41” from react-redux@9.0.2 npm ERR! node_modules/react-redux npm ERR! react-redux@“^9.0.0” from the root project npm ERR! peerOptional react-redux@“^7.2.1 || ^8.1.3 || ^9.0.0” from @reduxjs/toolkit@2.0.1 npm ERR! node_modules/@reduxjs/toolkit npm ERR! @reduxjs/toolkit@“^2.0.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. npm ERR! npm ERR! npm ERR! For a full report see: