Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Next.js and React

Module not found: Can't resolve '@material-ui/core' after an update or clone

ErrorModule not found: Can't resolve '@material-ui/core/Container'

Short answer

Material UI v4 was published as @material-ui/core. Since v5 the packages are named @mui/material and @mui/icons-material. Code that still imports the old names fails once the old package is gone. Install the new packages and run the preset-safe codemod on your source folder.

  • Applies to Material UI 7, React 19, Node.js 22
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    List every file that still imports the old scope.

    grep -rln "@material-ui/" src
  2. 2Match what you see, then jump to its fix

    1. 1The failing import starts with @material-ui/The code still uses the v4 package namesFix
    2. 2Imports like @mui/material/styles/createTheme fail after an upgradeOld multi level import paths on a newer versionFix
    3. 3@mui/material resolves, but @mui/icons-material or @mui/lab errors appearRelated Material UI packages on mixed versionsFix

What does the error look like?

  • Module not found: Can't resolve '@material-ui/core/Container'
  • Cannot find module '@material-ui/icons'

Cause 1 of 3

The code still uses the v4 package names

1Check

Material UI v5 renamed the packages: @material-ui/core is now @mui/material and @material-ui/icons is now @mui/icons-material.

grep -n "material-ui\|@mui" package.json

2Fix

Install the new packages with the Emotion styling engine they use, then run the codemod once per folder. It also removes the old @material-ui packages.

npm install @mui/material @emotion/react @emotion/styled
npm install @mui/icons-material
npx @mui/codemod@latest v5.0.0/preset-safe src

3Verify

Build the project and commit after the build is green.

npm run build

Confirmed by mui.com

Did this fix it?

Cause 2 of 3

Old multi level import paths on a newer version

1Check

Newer major versions no longer support multi level deep imports.

grep -rn "@mui/material/styles/" src

2Fix

Import from the first level path.

// before
import createTheme from '@mui/material/styles/createTheme'
// after
import { createTheme } from '@mui/material/styles'

3Verify

Rebuild the project.

npm run build

Confirmed by mui.com

Did this fix it?

Cause 3 of 3

Related Material UI packages on mixed versions

1Check

The sibling packages are versioned with the core package, so they should be moved together.

npm ls @mui/material @mui/icons-material @mui/lab

2Fix

Update the sibling packages to the same major version as @mui/material, and keep @types/react matching your React major version.

npm install @mui/material@latest @mui/icons-material@latest

3Verify

npm ls shows one version of each package.

npm ls @mui/material @mui/icons-material

Confirmed by mui.com

Did this fix it?

How do I stop it coming back?

  • Pin the Material UI major version in package.json and review the migration guide before moving it.
  • Run the codemod folder by folder and commit after each one.
  • Copy snippets from the current docs, not from old tutorials.

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:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.