10

I'm trying to connect my Redux store to my React project, but I keep getting this error:

../node_modules/react-redux/es/components/Provider.js Module not found: Can't resolve 'react' in 'C:\Users.\Documents..\node_modules\react-redux\es\components'

I've installed both react-redux and redux (I believe react-redux has some dependencies on redux)

import { Provider} from 'react-redux';

This is what is giving the error.

Any suggestions on what I could do?

5 Answers 5

14

This could be caused by your node_modules

First delete your node_modules, package-lock.json, and yarn.lock then install all dependencies again

like rm -rf node_modules package-lock.json yarn.lock

then run

npm install or yarn install

Sign up to request clarification or add additional context in comments.

1 Comment

ISN'T JAVASCRIPT GREAT!?
3

Please import react at top

import React from 'react'

Comments

2

I faced this issue and it seems you installed react-redux first and redux later.

I assume, react-redux is having some dependencies on redux, which might have created this error. So, recommending you to delete the package-lock.json , run npm install and then npm start.

Let me know if this works!

Thanks

1 Comment

Can you give me ur package.json? I want to see the version of both redux and react-redux
0

I had same issue, Just run npm audit fix to fix the error

Comments

0

A bit of a left-field answer, but turns out I'd configured react and react-dom as peerDependencies in my package.json. Moving them into regular dependencies did the trick.

(This is a common webpack error message, so anything building with webpack that expects a module it can't find will blow up with this same error).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.