MUI v5:无法解析“...\node_modules\@mui\styled-engine”中的“@emotion/react”

ani*_*lab 1 javascript frontend web-frontend reactjs material-ui

Module not found: Can't resolve '@emotion/react' in '...\node_modules\@mui\styled-engine'
Run Code Online (Sandbox Code Playgroud)

我在 ReactJS 项目中使用 Material-UI 时遇到编译失败的问题,我检查了 @muinode_modules文件夹,但无法修复编译错误。大家有什么想法请与我分享。

Nea*_*arl 7

在使用 MUI 之前,您应该浏览一下安装指南,看看是否有您可能缺少的必需软件包。在 v5 中,MUI 放弃了 JSS 样式库(实际上只是将其标记为过时,并计划在 v6 中将其删除),转而使用情感作为默认样式引擎。如果您不使用 styled-component 或任何其他第三方样式库并希望立即使用 MUI,则仍然需要安装情感才能使用 MUI 样式 API。

npm install @mui/material @emotion/react @emotion/styled
Run Code Online (Sandbox Code Playgroud)

相关答案