TeamWertarbyte / mdi-material-ui

Material-UI SvgIcon components for Material Design Icons.
MIT License
328 stars 15 forks source link

Can't resolve 'material-ui/SvgIcon' when building with webpack #8

Closed leonardiwagner closed 6 years ago

leonardiwagner commented 6 years ago

When building my react app with weback, for every icon inside this package is thrown that error:

ERROR in ./node_modules/mdi-material-ui/ViewDay.js
Module not found: Error: Can't resolve 'material-ui/SvgIcon' in '/MY_PROJECT_FOLDER/node_modules/mdi-material-ui'
 @ ./node_modules/mdi-material-ui/ViewDay.js 11:15-45
 @ ./node_modules/mdi-material-ui/index.es.js
 @ ./src/components/Menu/MenuContainer.js
 @ ./src/index.js
 @ multi (webpack)-dev-server/client?http://0.0.0.0:8080 ./src/index.js

I'm using webpack 3, npm 5, and material-ui@next (1.0.0-beta.40)

leonardiwagner commented 6 years ago

I think the problem is about using material-ui 1.0, with 0.20 builds fine. Any plans to be compatible with the newer version?

leonardiwagner commented 6 years ago

For those with the same problem, I started to use mdi-react lib instead and works fine with v1.

I did not spend time studying how could fix the problem but maybe using the required lib as dependency rather than relying on material-ui could be safer.

leMaik commented 6 years ago

@leonardiwagner I'm using it with material-ui 1.0.0 and it works perfectly fine. SvgIcon is still available in material-ui 1.0.0 as well as 0.x, I don't know why your webpack config doesn't work.

Without any more information, I can't help you, though. I changed the title, because this is definitely compatible with material-ui 1.0.0 :wink:

I did not spend time studying how could fix the problem

:(

orenkudev commented 6 years ago

I experienced a similar issue when Upgrading MaterialUI-icon from 1.0.0-beta43 to 1.0.0 For some reason the code generated using webpack still included the previous svgicon.js file.

I completely removed the node_modules directory and run npm install again. This solved the problem for me

owtham commented 5 years ago

@material-ui/icons have a peer dependency of @material-ui/core. @orenkudev answer helped me.