32

I imported the Slider:

import Slider from '@material-ui/lab/Slider';

and have returned in the render.

The code is not getting compiled and is throwing an error:

Module not found: Error: Can't resolve '@material-ui/lab/Slider' in {path}.

Could anyone help me with this? Thanks.

Jayendran
  • 9,638
  • 8
  • 60
  • 103
technoite
  • 323
  • 1
  • 3
  • 4

9 Answers9

69

You have to install the lab package: npm install @material-ui/lab

Pedro Brost
  • 1,402
  • 1
  • 14
  • 25
6

Updated answer as of February 2021: Slider has been moved into core, so you should change your import to:

import Slider from '@material-ui/core/Slider';
Bluby
  • 321
  • 2
  • 6
1

Run the following command in the your terminal/ cmd :

npm install @material-ui/lab

After successful installation, restart the server. It will work properly. You can check manually in your node_modules/@material-ui. You will find lab folder in it.

Rishav Kumar
  • 71
  • 1
  • 3
1

Error itself shout a lot.

Module not found

That means you've to install the module if its not part of your project.

lab doesn't come with material/core

Just install the lab package through any package manager NPM or YARN

npm

npm install @material-ui/lab

yarn

yarn add @material-ui/lab

I would suggest to use only one package at a time, And also check if the lock file exist. Sometimes it conflicts and cause issue with the existing packages.

Hidayt Raj
  • 13
  • 3
0

The solution that worked for me is the followin (use --save to save the dependencency in package.jso)

 npm install @material-ui/lab --save
Jorge Santos
  • 397
  • 4
  • 3
0

Try installing the npm package npm install @material-ui/lab. Incase this doesn't work please check your material-ui/core version and the material-ui/lab version you installed. You can’t use v3 of @material-ui/core with v4 of @material-ui/lab please upgrade core

Reference:

  1. https://github.com/mui-org/material-ui/issues/16319#issuecomment-504297322,
  2. https://github.com/mui-org/material-ui/issues/12124

Hope this helps.

Community
  • 1
  • 1
Thanmai C
  • 741
  • 1
  • 7
  • 10
0

I faced the same problem with Pagination from @material-ui/lab/Pagination and faced the same error because I just installed @material-ui/lab with version 4.0.0-alpha.57 but I was using old version of @material-ui/core which was below 4.0.

I uninstalled @material-ui/core and re-installed npm package and it solved the issue.

SecretAgentMan
  • 2,856
  • 7
  • 21
  • 41
0

I was able to resolve the issue after installing @mui/lab package with material ui 5.0.4.

For yarn users: yarn add @mui/lab

For npm users: npm install @mui/lab

Prime
  • 2,809
  • 1
  • 7
  • 23
0

Try to install both @material-ui/lab and @material-ui/core.

npm install @material-ui/lab
npm install @material-ui/core

The above tested for @material-ui/core v4.12 and @material-ui/lab v4.0.

You might also need MUI icons package installed (npm install @mui/material @emotion/react @emotion/styled): https://stackoverflow.com/a/71806305

Alex P.
  • 1,140
  • 13
  • 27