我正在尝试将 Gatsby 与 MUI 和 Styled-Components 结合使用。但是我收到以下错误消息: ModuleNotFoundError: Module not found: Error: Can't resolve '@emotion/react' 这是不寻常的,因为文档说样式化组件可以专门用作样式解决方案。
重现步骤:
gatsby new
选择默认值和样式组件作为样式系统npm install --save @mui/material @mui/styled-engine-sc styled-components
从 mui 安装 instructions for styled-componentsimport Button from "@mui/material/Button";
到 imports 和 <Button variant="contained">Hello World</Button>
。来自docs.gatsby develop
但它会失败 ModuleNotFoundError: Module not found: Error: Can't resolve '@emotion/react'
这就是问题所在。我尝试了什么:
npm i --save @emotion/react @emotion/styled
并且按钮呈现,但我不确定它是否呈现样式组件或情感,可能是情感。相关问题: