Can't resolve AdapterDateFns in MUI X Date Pickers
Module 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.
Fix it fast
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=02Match what you see, then jump to its fix
- 1
The failing path starts with @material-ui/lab or @mui/labThe import still points at the old lab packageFix - 2
The 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
The error names @mui/x-date-pickers itselfThe pickers package or its peer packages are not installedFix
- 1
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" src2Fix
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 buildConfirmed by mui.com
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=02Fix
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
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=02Fix
Install what is missing.
npm install @mui/x-date-pickers @mui/material @emotion/react @emotion/styled date-fns3Verify
The listing shows all five packages and the build passes.
npm ls @mui/x-date-pickers date-fns --depth=0Confirmed by mui.com
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:
- 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
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 fixWeb apps
An axios call never finishes when the API server stops answering
code: 'ECONNABORTED'
Axios has no timeout unless you give it one: the default is 0, which means wait forever.
3 causes, each with a fix