9
votes

EDIT: Just discovered that not one single module installed through npm install --save can be resolved. The issue seems to be therefore with all modules even though they are located inside node_modules folder.

I have been debugging this error for the last 2 hours. Note that the application has been created with create-react-app tool.

This is how I am importing the module:

import AppBar from "@material-ui/core/AppBar";
import Button from "@material-ui/core/Button";
import Icon from "@material-ui/core/Icon";
import IconButton from "@material-ui/core/IconButton";
import Tabs from "@material-ui/core/Tabs";
import Tab from "@material-ui/core/Tab";

This is the package.json snippet:

...
"dependencies": {
    "@material-ui/core": "^1.5.1",
    "@material-ui/icons": "^1.1.1",
...
5
Did you try to delete your node_modules and try again? - Anas
share you webpack config if it is importing node_modules - Sakhi Mansoor
@Anas yes I tried that already - James
@SakhiMansoor this app was create with create-react-app and just found out that all modules cannot be imported - James

5 Answers

14
votes

Try - yarn add @material-ui/core

This resolved the broken dependencies between materialui and react. Worked for me in my case, it was @material-ui/core/chippedInput that was missing.

11
votes

The solution that worked for me is the following:

npm install  @material-ui/core

Check the link https://www.npmjs.com/package/@material-ui/core

2
votes

I tried to use material-ui inside a docker container via docker-compose, when I got the same error. I had to reinitialize docker-compose via docker-compose down before running docker-compose up --build. Afterwards the import worked as expected.

1
votes

I came across this question while trying to work with the material-ui table. Additional to installing the @material-ui/core via npm, make sure you install npm install @material-ui/icons, from https://material-ui.com/getting-started/installation/#svg-icons

0
votes

What I noticed was, just by npm install it is not installing @material-ui/core package, we need to install it separately by npm install @material-ui/core. This method is the same for @material-ui/icons