Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
163
rated 0 times [  164] [ 1]  / answers: 1 / hits: 40564  / 3 Years ago, tue, september 21, 2021, 12:00:00

I am trying to import a box component from @mui/material/Box. I have installed MUI 5 using the following command npm i @mui/material.
But this error is occurring, Module not found: Can't resolve '@emotion/react' in 'E:frontendnode_modules@muistyled-engine'


Here is my code.


import * as React from 'react';
import Box from '@mui/material/Box';

export default function WhiteSpace() {
return (
<div style={{ width: 200 }}>
<Box
component="div"
sx={{
whiteSpace: 'nowrap',
my: 2,
bgcolor: 'background.paper',
}}
>
White Space Nowrap. White Space Nowrap.
</Box>
<Box
component="div"
sx={{
whiteSpace: 'normal',
my: 2,
bgcolor: 'background.paper',
}}
>
White Space Normal. White Space Normal.
</Box>
</div>
);
}

Can someone help me fix this?


More From » reactjs

 Answers
13

@emotion/react and @emotion/styled are peer dependencies of many mui packages, ie @mui/material. This gives us more freedom over which emotion version we would like to use, but does mean we must install the dependencies ourselves.


npm i @emotion/react @emotion/styled

[#50166] Friday, September 3, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
longd

Total Points: 616
Total Questions: 110
Total Answers: 101

Location: Andorra
Member since Sat, May 27, 2023
1 Year ago
;