Error module not found: Can't resolve 'react' in ReactJs

Dung Do Tien Jun 06 2021 401

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?

Have 2 answer(s) found.
  • N

    Nguyen Truong Giang Jun 06 2021

    Try removing package-lock.json, run npm install and then npm start again. Please also share your package.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

    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.

Leave An Answer
* NOTE: You need Login before leave an answer

* Type maximum 2000 characters.

* All comments have to wait approved before display.

* Please polite comment and respect questions and answers of others.

Popular Tips

X Close