简体   繁体   中英

React - Material UI | Module not found: Can't resolve 'material-ui/Button'

I am using material UI button on my react application page.

import Button from 'material-ui/Button'
<Button color="primary" variant="raised">
          Group
</Button>

I have installed below package -

npm install material-ui
npm install @material-ui/core
npm install --save material-ui@next

I referred all of this from existing question .

But it proved to be of no use.

I am getting - Module not found: Can't resolve 'material-ui/Button'

EDIT 1 :

After adding -

import Button from '@material-ui/Button'

I am getting -

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

As shown in the docs

You have to import it like this:

import Button from '@material-ui/core/Button';

// OR

import { Button } from '@material-ui/core'

You are importing from the incorrect path it should be import Button from '@material-ui/core/Button'; not import Button from '@material-ui/Button';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM