React cannot find the module @mui/x-data-grid
Module not found: Can't resolve '@mui/x-data-grid'Short answer
The bundler cannot find the package in node_modules. @mui/x-data-grid is a separate package from @mui/material, so install it, along with @mui/material, @emotion/react and @emotion/styled. If you installed the Pro or Premium package, import from that package name instead.
Fix it fast
1Find out which cause you have
Ask npm whether the package is installed in this project.
npm ls @mui/x-data-grid @mui/material @emotion/react @emotion/styled2Match what you see, then jump to its fix
- 1
npm ls prints (empty) for @mui/x-data-gridThe data grid package is not installedFix - 2
Related can't-resolve errors for @mui/material or @emotion/reactThe Material UI and Emotion peers are missingFix - 3
package.json lists @mui/x-data-grid-pro or @mui/x-data-grid-premium onlyPro or Premium is installed but the import names the community packageFix
- 1
What does the error look like?
Module not found: Can't resolve '@mui/x-data-grid'
Cause 1 of 3
The data grid package is not installed
1Check
Check package.json for the dependency.
grep -n "x-data-grid" package.json2Fix
Install the community package.
npm install @mui/x-data-grid3Verify
npm ls lists it and the build passes.
npm ls @mui/x-data-gridConfirmed by mui.com
Cause 2 of 3
The Material UI and Emotion peers are missing
1Check
The grid needs Material UI and Emotion beside it.
npm ls @mui/material @emotion/react @emotion/styled2Fix
Install the three peers.
npm install @mui/material @emotion/react @emotion/styled3Verify
Restart the dev server and open the page.
npm run devConfirmed by mui.com
Cause 3 of 3
Pro or Premium is installed but the import names the community package
1Check
Compare package.json with your import lines.
grep -rn "x-data-grid" package.json src/2Fix
Import from the package you installed.
import { DataGridPro } from '@mui/x-data-grid-pro';3Verify
The build resolves the import.
npm run buildConfirmed by mui.com
How do I stop it coming back?
- Install the grid and its peers in one command when you add it.
- Use one package (community, Pro or Premium) per project and import only from it.
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
Module not found: Can't resolve an @mui/icons-material icon import
Module not found: Can't resolve '@mui/icons-material/FileDownload'
The bundler cannot find a file at that import path.
3 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