简体   繁体   English

尝试导入错误:“alpha”未从“@material-ui/core/styles”导出

[英]Attempted import error: 'alpha' is not exported from '@material-ui/core/styles'

I'm trying to use the material-ui/lab date picker, however I'm getting this error!我正在尝试使用 material-ui/lab 日期选择器,但出现此错误! I have updated my material-ui version using npm install @material-ui/core@latest and it worked fine.我已经使用npm install @material-ui/core@latest更新了我的 material-ui 版本,它运行良好。 However, I lost the ability to use createMuiTheme & MuiThemeProvider .但是,我失去了使用createMuiTheme & MuiThemeProvider的能力。

Maybe it'll be helpful for someone.也许它会对某人有所帮助。 For me fix of that issue was to change the indirect import to direct one:对我来说,解决这个问题的方法是将间接导入更改为直接导入:

so this triggered the error:所以这触发了错误:

import { Alert } from '@material-ui/lab';

this works fine:这工作正常:

import Alert from '@material-ui/lab/Alert';

I had the same problem with Skeleton using version @material-ui/lab": "4.0.0-alpha.60 but changing it to version @material-ui/lab": "4.0.0-alpha.57 fixed it for me... guess they broke it again:)我在使用版本 @material-ui/lab 的 Skeleton 时遇到了同样的问题”:“4.0.0-alpha.60 但将其更改为版本 @material-ui/lab”:“4.0.0-alpha.57 为我修复了它...猜猜他们又把它弄坏了:)

You should update your package.json with following:您应该使用以下内容更新您的 package.json:

"@material-ui/lab": "4.0.0-alpha.57",
"@material-ui/pickers": "3.2.10",

I was using MUI v4 and was trying to use the Appbar from MUI, updating my MUI by running the command npm install @material-ui/core@latest and restarting the server by using npm start worked for Me, Hope this helps!!我正在使用 MUI v4 并尝试使用 MUI 中的 Appbar,通过运行命令npm install @material-ui/core@latest更新我的 MUI,并通过使用npm start重新启动服务器对我有用,希望这有帮助!!

I had to downgrade npm node@11.15.0 and npm install @material-ui/core@4.12.1 then it fixed all issues.我不得不降级npm node@11.15.0npm install @material-ui/core@4.12.1然后它解决了所有问题。 Please check node version with your node.请使用您的节点检查节点版本。

My material-ui version when first downloaded was an earlier version.首次下载时,我的 material-ui 版本是早期版本。 Then i ran:然后我跑了:

npm i -g npm-check-updates
ncu -u
npm install

to let it upgrade automatically to latest version.让它自动升级到最新版本。

Please try updating to latest version of @material-ui/core .请尝试更新到最新版本的@material-ui/core That should fix the issue.那应该可以解决问题。

i can't solve this problem with above solutions.我无法用上述解决方案解决这个问题。
so manually change 'alpha' to 'fade' in material ui files所以在材质 ui 文件中手动将 'alpha' 更改为 'fade'

./node_modules/@material_ui/lab/esm/ ./node_modules/@material_ui/lab/esm/

for example:例如:

import { fade, withStyles, useTheme } from '@material-ui/core/styles';从'@material-ui/core/styles'导入{淡入淡出,withStyles,useTheme};

instead反而

import { alpha, withStyles, useTheme } from '@material-ui/core/styles';从 '@material-ui/core/styles' 导入 { alpha, withStyles, useTheme };

it's works for me这对我有用
but it's not correct solutions.但这不是正确的解决方案。

update npm @material-ui/cor e package npm update resolved my issue更新npm @material-ui/cor e package npm update解决了我的问题

暂无
暂无

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

相关问题 尝试导入错误:“useThemeVariants”未从“@material-ui/styles”导出 - Attempted import error: 'useThemeVariants' is not exported from '@material-ui/styles' 尝试导入错误:“fade”未从“@material-ui/core/styles”导出 - Attempted import error: 'fade' is not exported from '@material-ui/core/styles' 尝试导入错误:“makeStyles”未从“@material-ui/core/styles”导出 - Attempted import error: 'makeStyles' is not exported from '@material-ui/core/styles' 尝试导入错误:“ImageList”未从“@material-ui/core”导出 - Attempted import error: 'ImageList' is not exported from '@material-ui/core' 在 Material UI 中使用骨架时,如何修复错误“alpha”未从“@material-ui/core/styles”导出 - How to fix the error 'alpha' is not exported from '@material-ui/core/styles' when using Skeleton in Material UI 尝试导入错误:“ToogleButton”未从“@material-ui/lab”导出 - Attempted import error: 'ToogleButton' is not exported from '@material-ui/lab' 尝试导入错误:“unstable_useId”未从“@material-ui/core/utils”导出(导入为“useId”) - Attempted import error: 'unstable_useId' is not exported from '@material-ui/core/utils' (imported as 'useId') 尝试导入错误:“useControlled”未从“@material-ui/core/utils”导出 - Attempted import error: 'useControlled' is not exported from '@material-ui/core/utils' 错误尝试导入错误:“NotificationsNoneIcon”未从“@material-ui/icons”导出 - error Attempted import error: 'NotificationsNoneIcon' is not exported from '@material-ui/icons' 尝试导入错误:“GlobalStyles”未从“@material-ui/system”导出(导入为“SystemGlobalStyles”) - Attempted import error: 'GlobalStyles' is not exported from '@material-ui/system' (imported as 'SystemGlobalStyles')
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM