material-ui icon indicating copy to clipboard operation
material-ui copied to clipboard

Example in README throws can't resolve 'material-ui/Button'

Open gordysc opened this issue 9 years ago • 27 comments

Problem description

Following the example on the README leads to:

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

Steps to reproduce

  1. Execute:
create-react-app example
cd example
yarn add material-ui@latest
// Modify App.js to include a <Button/> tag
yarn start

Example App.js:

import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
import Button from 'material-ui/Button';

class App extends Component {
  render() {
    return (
      <div className="App">
        <div className="App-header">
          <img src={logo} className="App-logo" alt="logo" />
          <h2>Welcome to React</h2>
        </div>
        <p className="App-intro">
          To get started, edit <code>src/App.js</code> and save to reload.
        </p>
        <Button>Example Button</Button>
      </div>
    );
  }
}

export default App;

Versions

  • Material-UI: ^0.19.0
  • React: ^15.6.1
  • Browser: Chrome 60.0.3112.101 (Official Build) (64-bit)

gordysc avatar Aug 23 '17 01:08 gordysc

You have mixed yarn add material-ui@latest@ and yarn add material-ui@next. Any idea how we could prevent such confusion? Otherwise, we can close.

oliviertassinari avatar Aug 23 '17 06:08 oliviertassinari

We just use both versions material-ui and naterial-ui-next

palaniichukdmytro avatar Aug 23 '17 06:08 palaniichukdmytro

Hi @oliviertassinari

I am getting this error after

npm install material-ui --save
yarn 
yarn start

offending line is:

import Button from 'material-ui/Button';

ErichBSchulz avatar Aug 27 '17 05:08 ErichBSchulz

i have same problem when i import Button from 'material-ui/Button'; i tried both npm and yarn, and i didnt found 'Button' module @ node_module/material-ui folder

williammw avatar Sep 08 '17 03:09 williammw

i have same problem when i import Button from 'material-ui/Button'; i tried both npm and yarn, and i didnt found 'Button' module @ node_module/material-ui folder

I'm having exactly the same problem.

Socratic1 avatar Sep 08 '17 19:09 Socratic1

I have same problem when I import Button from 'material-ui/Button'; i tried with npm and i didnt found 'Button' module @ node_module/material-ui folder

vaibhavi3t avatar Sep 14 '17 11:09 vaibhavi3t

Try npm install material-ui@next --save and restart the server, it should work!

cristobalchao avatar Sep 22 '17 06:09 cristobalchao

Still not working for me :( "material-ui": "^1.0.0-beta.16", Please help

shubhamkes avatar Oct 15 '17 12:10 shubhamkes

Got it sorted by removing entry from package.json and hit npm install material-ui

shubhamkes avatar Oct 15 '17 12:10 shubhamkes

I had the same issue, uninstalled it with $ npm uninstall material-ui and re installed it $ npm i material-ui@next. The Button error is gone, now I'm missing the material-ui/Menu module.

Oxyrus avatar Oct 20 '17 19:10 Oxyrus

Same here

radjivF avatar Oct 25 '17 04:10 radjivF

I was able to solve this problem by running npm install material-ui@next --save and then restarting the server!

arikaa avatar Oct 26 '17 21:10 arikaa

@arikaa I have try this too, Its Ok I move on to Bulma,

Cheers

radjivF avatar Oct 31 '17 06:10 radjivF

In latest material-ui use the below Button types instead of "material-ui/Button';"

import FlatButton from 'material-ui/FlatButton'; import RaisedButton from 'material-ui/RaisedButton'; import FloatingActionButton from 'material-ui/FloatingActionButton'; import IconButton from 'material-ui/IconButton';

udithaindika avatar Nov 10 '17 03:11 udithaindika

@udithaindika You're right that they changed the types, but now i'm getting the Can't resolve 'material-ui/FloatingActionButton' error.

Changing the import doesn't always help - remember to restart your server, that solved it for me.

borisyordanov avatar Nov 17 '17 13:11 borisyordanov

I fixed this error by this way. npm install material-ui@next --save The App code is import React, {Component} from 'react'; import Button from 'material-ui/Button' class App extends Component { render(){ return ( <Button> Welcome React</Button> ); } } export default App; May help you

Bobcui001 avatar Nov 22 '17 07:11 Bobcui001

I'm having similar issue and nothing I do through npm is fixing it.

If I use npm install material-ui --save then RaisedButton works. However, if I use npm install material-ui@next --save (beta.22) RaisedButton does not work (Button works) and I get a bunch of other issues too.

I'm importing RaisedButton like this: import RaisedButton from 'material-ui/RaisedButton';

Anyone knows why this is happening?

KIWI-JP avatar Dec 03 '17 09:12 KIWI-JP

@KIWI-JP perhaps material-ui will be removing the RaisedButton component some time in the future and they have already done that in beta.22?

Did you check if node_modules\material-ui\RaisedButton exists as a directory?

borisyordanov avatar Dec 03 '17 10:12 borisyordanov

Same problem. No RaisedButton in "node_modules\material-ui\RaisedButton".

djnsu avatar Dec 06 '17 20:12 djnsu

@djnsu Are you using the latest version of material-ui? The button should be there. I'm using 0.19.4 and i have it.

borisyordanov avatar Dec 06 '17 22:12 borisyordanov