繁体   English   中英

未找到模块:错误:无法解析“@material-ui/core/styles”(部署到 heroku 时)

[英]Module not found: Error: Can't resolve '@material-ui/core/styles' (when deploying to heroku)

我有一个反应应用程序并尝试将其部署到 Heroku 并在运行时git push heroku master

未找到模块:错误:无法解析“@material-ui/core/styles”

我搜索了类似的问题并安装了最新版本的 npm、node 和 metal-ui,我还尝试npm install @material-ui/core ..没用。

这是完整的错误日志文件

-----> 构建成功:=====> 正在下载 Buildpack: https://github.com/mars/create-react-app-inner-buildpack.git =====> 检测到的框架:React。 js (create-react-app) Writing static.json to support create-react-app Enabling runtime environment variables amusement-parks-europe@0.1.0 build /tmp/build_a49639db14111a3c4e29b2f3e9e25c49 react-scripts build Creating an optimized production build... Failed编译。 找不到模块:错误:无法解析“/tmp/build_a49639db14111a3c4e29b2f3e9e25c49/src”npm ERR 中的“@material-ui/core/styles”。 代码 ELIFECYCLE npm 错误。 errno 1 npm ERR:amusement-parks-europe@0.1.0 build: react-scripts build npm ERR。 退出状态 1 npm ERR。 npm 错误。 在 amusement-parks-europe@0.1.0 构建脚本失败:npm ERR。 这可能不是 npm 的问题。 上面可能还有额外的日志记录 output,npm ERR。 可以在 npm ERR 中找到此运行的完整日志! /app/.npm/_logs/2018-10-08T20_29_28_807Z-debug.log ! 推送被拒绝,无法编译 React.js (create-react-app) 多应用程序。 推送失败

该项目可以在 github react app using google Api上找到

感谢您的帮助,我尝试了很多想法,但没有解决。

看来您的package.json文件不包含material-ui。 尝试'npm i -s @ material-ui / core'

根据@samokasha的回答解决了问题,解决方案是使用npm install @material-ui/core --save

我之前使用过相同的命令,但是错过了--save

谢谢您的帮助。

检查你的反应版本和

npm install @material-ui/core --save

或者

npm 安装@material-ui/core@next

如果你使用的是 MUI 5 你需要改变这个

v5
import { withStyles } from '@mui/material/styles';


V4
import { withStyles } from '@material-ui/core/styles';

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM