Error module not found: Can't resolve 'react' in ReactJs
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
import React, { Component } from 'react';
import ReactDOM, { render } from 'react-dom';
import { Provider} from 'react-redux';
How can I resolve it?
-
N-5
Nguyen Truong Giang Jun 06 2021
Try removing
package-lock.json
, runnpm install
and thennpm start
again. Please also share yourpackage.json
file.If it doesn't help, install an older version of npm (e.g. 3.x). 5.x is still fairly buggy and might be causing this.
I'll close because it is not an issue on our side. npm just failed to install the
react
module for some reason. -
T-14
Tu Hoang Jun 06 2021
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 using
like
rm -rf node_modules
rm -rf package-lock.json
rm -rf yarn.lock
then run
npm install
I hope it resolves that issue for you.
* Type maximum 2000 characters.
* All comments have to wait approved before display.
* Please polite comment and respect questions and answers of others.