Maaz Zindani

Loading the index…

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

Can't resolve AdapterDateFns in MUI X Date Pickers

ErrorModule not found: Can't resolve '@material-ui/lab/AdapterDateFns'

Short answer

The date pickers left @mui/lab and now live in @mui/x-date-pickers. Import the adapter from @mui/x-date-pickers/AdapterDateFns for date-fns 3 or 4, or from AdapterDateFnsV2 for date-fns 2. Install the pickers package and date-fns, and drop any @material-ui/lab or @mui/lab import.

  • Applies to @mui/x-date-pickers 8, date-fns 4, React 19, Node.js 22
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    List the date picker and date-fns packages the project has. The versions decide which import path is right.

    npm ls @mui/x-date-pickers @mui/lab @material-ui/lab date-fns --depth=0
  2. 2Match what you see, then jump to its fix

    1. 1The failing path starts with @material-ui/lab or @mui/labThe import still points at the old lab packageFix
    2. 2The import already uses @mui/x-date-pickers, and the error appears for one adapter path or for date-fns filesThe adapter path does not match the installed date-fns major versionFix
    3. 3The error names @mui/x-date-pickers itselfThe pickers package or its peer packages are not installedFix

What does the error look like?

  • Module not found: Can't resolve '@material-ui/lab/AdapterDateFns'
  • Module not found: Can't resolve '@mui/lab/AdapterDateFns'
  • Can't resolve '@mui/x-date-pickers/AdapterDateFns'

Cause 1 of 3

The import still points at the old lab package

1Check

The pickers moved out of the lab packages into @mui/x-date-pickers. Search for leftover imports.

grep -rn -E "@material-ui/lab|@mui/lab" src

2Fix

Install the new package and change the imports. A codemod from MUI rewrites component imports for you; the adapter and provider you then import from the new package.

npm install @mui/x-date-pickers date-fns
npx @mui/codemod v5.0.0/date-pickers-moved-to-x src

// then, in code:
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';

3Verify

No lab import is left and the build resolves the adapter.

grep -rn -E "@material-ui/lab|@mui/lab" src
npm run build

Confirmed by mui.com

Did this fix it?

Cause 2 of 3

The adapter path does not match the installed date-fns major version

1Check

The adapter page lists date-fns 2, 3 and 4 as supported, but one adapter cannot serve every major version, because date-fns 3 changed how functions are exported. Read the installed major version.

npm ls date-fns --depth=0

2Fix

For date-fns 3 or 4, import AdapterDateFns and take locales as named exports. For date-fns 2, use the AdapterDateFnsV2 path and default locale imports.

// date-fns 3.x or 4.x
import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';
import { de } from 'date-fns/locale/de';

// date-fns 2.x
import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFnsV2';
import de from 'date-fns/locale/de';

3Verify

Wrap the app once and render a picker.

<LocalizationProvider dateAdapter={AdapterDateFns} adapterLocale={de}>
  <DatePicker />
</LocalizationProvider>

Confirmed by mui.com

Did this fix it?

Cause 3 of 3

The pickers package or its peer packages are not installed

1Check

The quickstart needs the pickers package, a date library, and the MUI core packages as peers.

npm ls @mui/x-date-pickers @mui/material @emotion/react @emotion/styled --depth=0

2Fix

Install what is missing.

npm install @mui/x-date-pickers @mui/material @emotion/react @emotion/styled date-fns

3Verify

The listing shows all five packages and the build passes.

npm ls @mui/x-date-pickers date-fns --depth=0

Confirmed by mui.com

Did this fix it?

How do I stop it coming back?

  • Wrap the app in one LocalizationProvider near the root, as the MUI docs advise, and import the adapter in that one file.
  • Pin the date-fns major version, and read the MUI adapter page before you bump it.
  • Run the MUI codemod when you upgrade MUI major versions.

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.