material ui lab date picker, Can't resolve '@material-ui/lab/AdapterDateFns'

Viewed 43315

Can't resolve '@material-ui/lab/AdapterDateFns'

Can't resolve '@material-ui/lab/DateTimePicker'

Can't resolve '@material-ui/lab/LocalizationProvider'

I am getting these errors even after having installed @material-ui/lab

4 Answers

This works for me very well

npm install @mui/lab

In Material UI v5 you need to install @mui/lab.My dependencies are here :

  "dependencies": {
    "@mui/lab": "^5.0.0-alpha.54",
    "@mui/material": "^5.2.1",
  }

For more information check this link

I have a working codesandbox here: https://codesandbox.io/s/youthful-wave-8xjy4

Make sure both @material-ui/core and @material-ui/lab are at version "5.0.0-alpha.24" or above as I ran into the same import errors as you when following the guide at: https://next.material-ui.com/guides/pickers-migration/

// package.json
{
  "dependencies": {
    "@emotion/react": "11.1.5",
    "@emotion/styled": "11.1.5",
    "@material-ui/core": "5.0.0-alpha.24",
    "@material-ui/lab": "5.0.0-alpha.24",
    "date-fns": "2.17.0",
    "react": "17.0.1",
    "react-dom": "17.0.1",
    "react-scripts": "4.0.0"
  },
}

Try running npm install @material-ui/core@next and npm install @material-ui/lab@next

This should move you to version 5.

If the need arises, delete the node_modules folder and run npm install.

Now if you look into the lab folder in node_modules/@material-ui, you will see the

Related