简体   繁体   English

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

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

i have a react application and trying to deploy it to Heroku and when runnung git push heroku master我有一个反应应用程序并尝试将其部署到 Heroku 并在运行时git push heroku master

Module not found: Error: Can't resolve '@material-ui/core/styles'未找到模块:错误:无法解析“@material-ui/core/styles”

I searched for similar issues and installed the latest versions of npm, node and metarial-ui also i tried npm install @material-ui/core ..didn't work.我搜索了类似的问题并安装了最新版本的 npm、node 和 metal-ui,我还尝试npm install @material-ui/core ..没用。

here is the full error-log file这是完整的错误日志文件

-----> Build succeeded: =====> Downloading Buildpack: https://github.com/mars/create-react-app-inner-buildpack.git =====> Detected Framework: 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 to compile. -----> 构建成功:=====> 正在下载 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编译。 Module not found: Error: Can't resolve '@material-ui/core/styles' in '/tmp/build_a49639db14111a3c4e29b2f3e9e25c49/src' npm ERR.找不到模块:错误:无法解析“/tmp/build_a49639db14111a3c4e29b2f3e9e25c49/src”npm ERR 中的“@material-ui/core/styles”。 code ELIFECYCLE npm ERR.代码 ELIFECYCLE npm 错误。 errno 1 npm ERR: amusement-parks-europe@0.1.0 build: react-scripts build npm ERR. errno 1 npm ERR:amusement-parks-europe@0.1.0 build: react-scripts build npm ERR。 Exit status 1 npm ERR.退出状态 1 npm ERR。 npm ERR. npm 错误。 Failed at the amusement-parks-europe@0.1.0 build script: npm ERR.在 amusement-parks-europe@0.1.0 构建脚本失败:npm ERR。 This is probably not a problem with npm.这可能不是 npm 的问题。 There is likely additional logging output above, npm ERR.上面可能还有额外的日志记录 output,npm ERR。 A complete log of this run can be found in. npm ERR!可以在 npm ERR 中找到此运行的完整日志! /app/.npm/_logs/2018-10-08T20_29_28_807Z-debug.log ! /app/.npm/_logs/2018-10-08T20_29_28_807Z-debug.log ! Push rejected, failed to compile React.js (create-react-app) multi app.推送被拒绝,无法编译 React.js (create-react-app) 多应用程序。 ! Push failed推送失败

and the project can be found on github react app using google Api该项目可以在 github react app using google Api上找到

thanks for any help, I tried many ideas and came to no solution.感谢您的帮助,我尝试了很多想法,但没有解决。

Looks like your package.json file doesn't include material-ui. 看来您的package.json文件不包含material-ui。 Try 'npm i -s @material-ui/core' 尝试'npm i -s @ material-ui / core'

the problem was solved according to the answer from @samokasha , the solution was using npm install @material-ui/core --save 根据@samokasha的回答解决了问题,解决方案是使用npm install @material-ui/core --save

I used the same command before but I missed the --save 我之前使用过相同的命令,但是错过了--save

thanks for the help. 谢谢您的帮助。

check your react version and检查你的反应版本和

npm install @material-ui/core --save npm install @material-ui/core --save

or或者

npm install @material-ui/core@next npm 安装@material-ui/core@next

If you are using MUI 5 You need to change this如果你使用的是 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.

相关问题 找不到模块:无法解析“@material-ui/styles”(反应) - Module not found: Can't resolve '@material-ui/styles' (React) "未找到模块:无法解析“material-ui\/styles\/colors”" - Module not found: Can't resolve 'material-ui/styles/colors' 找不到模块:无法解析“@material-ui/core/AppBar” - Module not found: Can't resolve '@material-ui/core/AppBar' 找不到模块:无法解析“@material-ui/core/Container” - Module not found: Can't resolve '@material-ui/core/Container' 找不到模块:无法解析“@material-ui/core/Breadcrumbs” - Module not found: Can't resolve '@material-ui/core/Breadcrumbs' 无法在'@ material-ui \ core \ Box'中解析'@ material-ui / styles / styled' - Can't resolve '@material-ui/styles/styled' in '@material-ui\core\Box' Material-UI 无法解析 '@material-ui/core/styles/createMuiTheme - Material-UI Can't resolve '@material-ui/core/styles/createMuiTheme 导入错误:在使用 @material-ui/core/styles/ThemeProvider/ 和 @material-ui/core/styles/createMuiTheme/ 时找不到模块 - import error: Module not found on using @material-ui/core/styles/ThemeProvider/ and @material-ui/core/styles/createMuiTheme/ 找不到模块:错误:无法解析“C:\Users\Meenakshi\OneDrive\Documents\react apps\memories\client\src”中的“@material-ui/core” - Module not found: Error: Can't resolve '@material-ui/core' in 'C:\Users\Meenakshi\OneDrive\Documents\react apps\memories\client\src' 如何解决找不到模块:无法在 Material-UI 中解析“@babel/runtime/core-js/map” - How to solve Module not found: Can't resolve '@babel/runtime/core-js/map' in Material-UI
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM