Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 713
Mohan Avatar asked Feb 09 '21 04:02

Mohan


People also ask

Is @material-UI/lab/adapterdatefns supported with the date-FNS library?

I think that @material-ui/lab/AdapterDateFns will be supported with the date-fns library. I read it at mui documentation for React Date Picker.

What happened to @material-UI/pickers?

@material-ui/pickers was moved to the @mui/lab. ⚠️ The date picker components were rewritten. In most places, the logic was rewritten from scratch, so it isn't possible to maintain the whole list of changes. Here's an overview of the most important concepts that were changed.

How to update material-UI to version 5?

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 Show activity on this post. Show activity on this post.

How to show activity in material-UI lab?

Now if you look into the lab folder in node_modules/@material-ui, you will see the Show activity on this post. Show activity on this post. Make sure that you installed a date management library. I think that @material-ui/lab/AdapterDateFns will be supported with the date-fns library.


Video Answer


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

like image 26
Samira Avatar answered Oct 16 '22 19:10

Samira


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"
  },
}
like image 55
aznbanana9 Avatar answered Oct 16 '22 17:10

aznbanana9


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

like image 6
Nayan Verma Avatar answered Oct 16 '22 18:10

Nayan Verma


Make sure that you installed a date management library. I think that @material-ui/lab/AdapterDateFns will be supported with the date-fns library.

date-fns installation

I read it at mui documentation for React Date Picker.

like image 1
OPaulo Avatar answered Oct 16 '22 19:10

OPaulo