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?
To solve the "Module not found: Can't resolve" error in React, make sure to install the package from the error message if it's a third-party package, e.g. npm i somePackage . If you got the error when importing local files, correct your import path.
import React from 'react'; import ReactDOM from 'react-dom'; import { createRoot } from 'react-dom/client'; import Switch from './components/Switch'; const root = ReactDOM. createRoot(document. getElementById('root')); root. render( <React.
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
Please import react at top
import React from 'react
'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With