2

I've got a quick question. I have react and all included but I want to import component from a material-ui library and the path is all good but it cannot find the module.

My code:

import React from 'react';
import ReactDOM from 'react-dom';
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
import RaisedButton from 'material-ui/RaisedButton';

var Comp = React.createClass({
	render(){
    return(
      <p>aa</p>
    );
  }
});

ReactDOM.render(
 <Comp />,
 document.getElementById('app')
);

Just a base code.

This is the error in the console:

Uncaught Error: Cannot find module "material-ui/styles/MuiThemeProvider"
    at webpackMissingModule (App.js:57)
    at Object.<anonymous> (App.js:57)
    at __webpack_require__ (App.js:20)
    at App.js:40
    at App.js:43

And that is files folder:

enter image description here

So, what's wrong?

2 Answers 2

3

Your material-ui folder should be in node_modules

Delete your material-ui folder and run npm install material-ui

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks a lot, I must say that I really have forgotten about that, thanks :)
I've got one more question. I'm also trying to import a react-tap-event-plugin. So I've got it in a node-modules folder but I'm still getting error.
npm install react-tap-event-plugin then follow these lines : github.com/callemall/material-ui#react-tap-event-plugin
MuiThemeProvider was moved to core/styles: import MuiThemeProvider from '@material-ui/core/styles/MuiThemeProvider';
1

I fixed the problem by installing new version:

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

// with yarn
yarn add @material-ui/core@next

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.