How to fix “Module not found: Can’t resolve ‘redux'” in React

The error “Module not found: Can’t resolve ‘redux'” in React appears when you try to access the redux library that your program is missing. Please read the article to know the cause of the error and solutions to fix it in detail.

The reason for the error “Module not found: Can’t resolve ‘redux'” in React

Redux is a Javascript library that helps us manage the application’s state. Redux can be combined with ReactJS perfectly because it is based on the ideology of Flux – introduced by Facebook a few years ago.

Without using Redux, components will communicate with each other using props. If we need to get the state of a component 3 floors apart, we have to call it 3 times, making the code and state management very complicated and getting more prominent over time.

If you still need to install the redux library and still import it into the code, the module not found error will appear and interfere with your work, like the example below.


import { createStore } from "redux";

const store = createStore(reducer);


As in the example above, we import createStore from the redux library to create a store for the component. The program will immediately give an error because webpack can’t find the library in the React project’s directory structure.

How to fix this error

Installing the ‘redux’ library

If your React program runs with an error “Module not found: Can’t resolve ‘redux'” in React, then most likely the problem is coming from the fact that you have not installed the ‘redux’ library on your project. We can install this library using the npm or yarn command below.


npm install redux react-redux

yarn add redux react-redux

When you run this command in the terminal, wait until the program has finished installing the package for the project, rerun the program, and the error will no longer appear.

Once the ‘redux’ library is installed, webpack will detect the package and the path to access its library of functions within the directory structure. As in the above example, we import the ‘createStore’ function to use inside the ‘redux’ package.

Checking the dependencies in the package.json file

If you have installed the library and still see the error, you can check the dependencies in the package.json file to see if ‘redux’ is defined like the code below.


"dependencies": {
     "react-redux": "^8.0.5",

When you finish installing the package with npm or yarn, automatically in the package.json file, there will be dependencies of the library you just installed. Here we have installed the latest version of the ‘redux’ library is 8.0.5. Wish you success with the methods mentioned in the article


In summary, the article has told us the cause and solutions for the error “Module not found: Can’t resolve ‘redux'” in React. However, we recommend installing the ‘redux’ library because that will be the most comprehensive solution.

Leave a Reply

Your email address will not be published. Required fields are marked *