Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Module not found: Can't resolve 'material-ui/AutoComplete'

I installed material-ui-search-bar and then I want to use SearchBar. But I have next problem:

./node_modules/material-ui-search-bar/lib/components/SearchBar/SearchBar.js
Module not found: Can't resolve 'material-ui/AutoComplete' in '...node_modules/material-ui-search-bar/lib/components/SearchBar'

How can I fix it?

like image 686
Just Snake Avatar asked Oct 18 '17 18:10

Just Snake


4 Answers

AutoComplete is associated with Lab package of material UI. On Adding the "lab" package AutoComplete can be used. Add using yarn

yarn add @material-ui/lab

or using npm

npm install @material-ui/lab
like image 165
Jayabharathi Palanisamy Avatar answered Nov 20 '22 10:11

Jayabharathi Palanisamy


I cannot upvote nor comment, so I just parrot the working solution. Thanks, @blackspacer.

This works:

npm install @material-ui/lab

One expects all Material UI elements to be present after the initial package install, but there is an exception.

https://material-ui.com/components/about-the-lab/

About the lab

This package hosts the incubator components that are not yet ready to move to the core.

Installation Install the package in your project directory with:

// with npm

npm install @material-ui/lab

// with yarn

yarn add @material-ui/lab

like image 32
Ragnar Kurm Avatar answered Nov 20 '22 09:11

Ragnar Kurm


Install material-ui using this command :

npm install material-ui@latest
like image 7
Jayaram Ramanarayanan Avatar answered Nov 20 '22 08:11

Jayaram Ramanarayanan


This can happen due to multiple reasons.

1) You are using the beta version of v1.0 launch of material-ui which has breaking changes. Try switching to the stable version. Or if you want to use the latest beta version, then use Refer below link: https://material-ui-next.com/demos/autocomplete/material-ui AutoComplete

2) Try importing like below:

import AutoComplete from 'material-ui/AutoComplete';

or

import { AutoComplete } from 'material-ui/AutoComplete';

Due to the port going on for @next version the modules are being reorganized and hence few components are breaking.

like image 3
blackspacer Avatar answered Nov 20 '22 10:11

blackspacer