Module not found: can't resolve 'redux' or 'react-redux'
Module not found: Error: Can't resolve 'redux'Short answer
The build cannot find a package that is not installed in this project. Redux Toolkit, React Redux and Redux core are separate packages. Install what you import, and prefer importing from @reduxjs/toolkit, which already re-exports the Redux core.
Fix it fast
1Find out which cause you have
See which Redux packages the project really has, and compare with the packages your imports name.
npm ls redux @reduxjs/toolkit react-redux grep -rhn "from 'redux'\|from \"redux\"\|react-redux" src | sort -u2Match what you see, then jump to its fix
- 1
The missing package is react-redux, while @reduxjs/toolkit is installedreact-redux is not installed, because it is not part of Redux ToolkitFix - 2
The missing package is redux, with imports such as combineReducers or applyMiddlewareThe code imports from 'redux' but only Redux Toolkit is installedFix - 3
Every Redux import fails, often right after cloning a repository or copying a component from another projectNeither package is installed in this projectFix
- 1
What does the error look like?
Module not found: Error: Can't resolve 'redux'Module not found: Error: Can't resolve 'react-redux'
Cause 1 of 3
react-redux is not installed, because it is not part of Redux Toolkit
1Check
React Redux is the binding between React and Redux, and it is not bundled with Redux Toolkit. It is a separate install.
npm ls react-redux2Fix
Install it.
npm install react-redux3Verify
The import of Provider and hooks resolves.
npm run buildConfirmed by redux.js.org
Cause 2 of 3
The code imports from 'redux' but only Redux Toolkit is installed
1Check
Redux Toolkit re-exports the Redux core, so most apps never install redux separately. An import from 'redux' needs that package to be a direct dependency of your project.
grep -rn "from 'redux'" src2Fix
Import the same functions from @reduxjs/toolkit. Use configureStore instead of the old createStore.
import { configureStore, combineReducers } from "@reduxjs/toolkit";
const rootReducer = combineReducers({ todos: todosReducer });
export const store = configureStore({ reducer: rootReducer });3Verify
The build passes with no import of 'redux' left.
grep -rn "from 'redux'" src; npm run buildConfirmed by redux.js.org
Cause 3 of 3
Neither package is installed in this project
1Check
The npm commands install Redux Toolkit and React Redux separately. Nothing in a fresh project provides them.
npm ls @reduxjs/toolkit react-redux2Fix
Install both, then restart the dev server.
npm install @reduxjs/toolkit react-redux3Verify
npm ls lists both packages.
npm ls @reduxjs/toolkit react-reduxConfirmed by redux.js.org
How do I stop it coming back?
- Install Redux Toolkit and React Redux together in every new React project.
- Import Redux core functions from @reduxjs/toolkit in new code.
- Commit the lock file so every machine installs the same packages.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- QistLockA NestJS and React SaaS driving an Android Device Owner agent that locks financed phones when payments lapse.
- WorkforceA field app, an admin console and a self-hosted Node.js server for push and reconciliation.
Related fixes
Web apps
createStore is struck through and marked @deprecated in Redux
createStore shown with a strikethrough and marked @deprecated in the editor
createStore is marked @deprecated since Redux 4.2.0, which only draws a strikethrough in your editor.
2 causes, each with a fixWeb apps
React shows Attempted import error when importing a component or function
Attempted import error:
The build found the file but not the name you asked for.
2 causes, each with a fixWeb apps
AxiosError Network Error with code ERR_NETWORK in a React app
Network Error
ERR_NETWORK means the request produced no readable response.
4 causes, each with a fixWeb apps
Axios get works with a URL string but ignores the object passed as the second argument
The server log shows a GET with no query string
axios.get takes a URL and an optional config object.
3 causes, each with a fixWeb apps
Can't resolve '../axios' in a React project
Module not found: Error: Can't resolve '../axios'
A path that starts with ./ or ../ is a file path, not the axios package.
3 causes, each with a fixWeb apps
Axios returns 401 from a React app but the login works elsewhere
Error: Request failed with status code 401
A 401 means the server received the request without valid credentials.
3 causes, each with a fix