Module not found: Can't resolve 'react'
Solution 1
This could be caused by your node_modules
At the first delete your node_modules, package-lock.json, yarn.lock then install all dependencies again
like
rm -rf node_modules
rm -rf package-lock.json
rm -rf yarn.lock
then run
npm install
Solution 2
Please import react at top
import React from 'react
'
Solution 3
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
econCodergirl
Updated on July 12, 2022Comments
-
econCodergirl almost 2 years
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
andredux
(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?
-
Kannan G over 4 yearsCan you give me ur package.json? I want to see the version of both redux and react-redux