Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to install @reduxjs/toolkit on Next.js project #2166

Closed
DGamer007 opened this issue Apr 29, 2024 · 7 comments
Closed

Unable to install @reduxjs/toolkit on Next.js project #2166

DGamer007 opened this issue Apr 29, 2024 · 7 comments

Comments

@DGamer007
Copy link

I was creating a new Next.js application with redux example; and I encountered this issue.

image

This issue arises even when I am trying to install @reduxjs/toolkit in existing Next.js project with npm install --save @reduxjs/toolkit.

I am currently trying on Kali Linux. But I replicated this issue on Ubuntu as well. Somehow, it seems to work on Windows.

@aryaemami59
Copy link
Contributor

@DGamer007 What does your package.json look like?

@aryaemami59
Copy link
Contributor

aryaemami59 commented Apr 29, 2024

Looks like this is happening due to react-native having a peer dependency of "react": "18.2.0" instead of "react": "^18.2.0" which causes an issue if you have "react": "^18.2.0" since the latest version of React is now 18.3.1 which is different from 18.2.0 hence why NPM throws an error due to this version mismatch. So you can either do npm install --force or you can change the version of react in your package.json to be "18.2.0" instead of "^18.2.0". Same goes for react-dom since react-dom v18.3.0 has a peer dependency of "react": "^19.0.0" for some reason.

On a side note, this issue seems similar to #2161.

@DGamer007
Copy link
Author

DGamer007 commented Apr 30, 2024

Looks like this is happening due to react-native having a peer dependency of "react": "18.2.0" instead of "react": "^18.2.0" which causes an issue if you have "react": "^18.2.0" since the latest version of React is now 18.3.1 which is different from 18.2.0 hence why NPM throws an error due to this version mismatch. So you can either do npm install --force or you can change the version of react in your package.json to be "18.2.0" instead of "^18.2.0". Same goes for react-dom since react-dom v18.3.0 has a peer dependency of "react": "^19.0.0" for some reason.

On a side note, this issue seems similar to reduxjs/react-redux#2161.

Yes, the --force option did resolve the issue but I don't think it would be feasible for deployment steps.

@aryaemami59
Copy link
Contributor

@DGamer007 This is more of an issue with React Native than it is with redux-toolkit. I did however submit a pull request to fix it facebook/react-native#44325.

@DGamer007
Copy link
Author

Roger that ! Thanks.

@markerikson
Copy link
Contributor

Ultimately this is an issue on the React-Redux side (and really it's an NPM issue), so I'll transfer it to the React-Redux repo.

@markerikson markerikson transferred this issue from reduxjs/redux-toolkit May 1, 2024
@markerikson
Copy link
Contributor

This should be fixed now that React-Redux 9.1.2 is out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants