Reputation: 313
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?
Upvotes: 10
Views: 47865
Reputation: 3238
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
Upvotes: 14
Reputation: 72885
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).
Upvotes: 0
Reputation: 1004
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
Upvotes: 2