Module not found: Error: Can't resolve '@material-ui/core' and '@material-ui/icons'
See original GitHub issueDescription
When I use rjsf out-of-the-box, right after installation I get some unnecessary warnings in the console.
Steps to Reproduce
- Import form for MUI version 5.
- Observe warnings in the console.
Expected behavior
No warnings.
Actual behavior
I use rjsf as follows with Material UI version 5.
import { MuiForm5 as Form } from '@rjsf/material-ui';
<Form schema={schema}>
<></>
</Form>
That gives me the following warning in the console:
WARNING in ../../node_modules/@rjsf/material-ui/dist/material-ui.esm.js 1139:21-49
Module not found: Error: Can't resolve '@material-ui/core' in '/... ... .../node_modules/@rjsf/material-ui/dist'
...
WARNING in ../../node_modules/@rjsf/material-ui/dist/material-ui.esm.js 1140:23-52
Module not found: Error: Can't resolve '@material-ui/icons' in '/... ... .../node_modules/@rjsf/material-ui/dist'
Version
From package.json:
"@emotion/react": "^11.7.1",
"@emotion/styled": "^11.6.0",
"@mui/icons-material": "^5.4.4",
"@mui/material": "^5.3.1",
"@rjsf/core": "^4.1.0",
"@rjsf/material-ui": "^4.1.0",
Issue Analytics
- State:
- Created 2 years ago
- Reactions:8
- Comments:62 (17 by maintainers)
Top Results From Across the Web
Module not found: Can't resolve '@material-ui/core/Container'
The solution for this problem will be to install core material UI and other MUI packages using the old naming conversion for example ......
Read more >Module not found: Can't resolve 'material-ui-icons/Menu ...
I have both Icons and Core installed. The SearchIcon is returning a similar error: **Failed to Compile Module not found: '@material-ui/icons/ ...
Read more >Module not found: Can't resolve '@mui/material' | bobbyhadz
To solve the error "Module not found: Error: Can't resolve '@mui/material'", make sure to install the package by opening your terminal in your...
Read more >@material-ui/core - npm
React components that implement Google's Material Design. ... Start using @material-ui/core in your project by running `npm i ...
Read more >module not found: error: can't resolve '@material-ui/core/styles
The solution for this problem will be to install core material UI and other MUI packages using the old naming conversion for example...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’m checking with some other library authors to see if there are other, more recommended ways, to include optional dependencies that avoid these problems.
Otherwise, we will just have to split @rjsf/material-ui into two libraries.
This is a known issue with the way Mui 4 and 5 support were built to be side-by-side. There are webpack tricks that can be used to eliminate the warnings.
Webpack 5
Add the following in your
webpack.config.js
to eliminate the errors for Material-UI v5 when you are only using v4:Add the following in your
webpack.config.js
to eliminate the errors for Material-UI v4 when you are only using v5:Webpack 4
Add the following in your
webpack.config.js
to eliminate the errors for Material-UI v5 when you are only using v4:Add the following in your
webpack.config.js
to eliminate the errors for Material-UI v4 when you are only using v5: