简体   繁体   English

在 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

I am using Material UI and I am getting a nasty error on Ubuntu with the Skeleton component.我正在使用 Material UI,但在 Ubuntu 上的骨架组件出现严重错误。 While on Windows I do not get this error and everything works fine, on Ubuntu I am getting the following error:在 Windows 上我没有收到此错误并且一切正常,在 Ubuntu 上我收到以下错误:

./node_modules/@material-ui/lab/esm/Skeleton/Skeleton.js
Attempted import error: 'alpha' is not exported from '@material-ui/core/styles'.

The import is taken from the official docs:导入取自官方文档:

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

On windows package.json my dependencies are these and all works fine:在 windows package.json 上,我的依赖项是这些并且一切正常:

"@material-ui/core": "^4.11.4",
"@material-ui/icons": "^4.11.2"

On Ubuntu it tells me that the lab is missing (and it is actually where the Skeleton should be, I do not know why on Windows it works despite not having the lab installed), so after I installed the lab the package.json on Ubuntu is this:在 Ubuntu 上,它告诉我实验室丢失了(它实际上是骨架应该在的地方,我不知道为什么在 Windows 上它可以工作,尽管没有安装实验室),所以在我安装实验室后,Ubuntu 上的 package.json 就是这个:

"@material-ui/core": "^4.11.4",
"@material-ui/icons": "^4.11.2",
"@material-ui/lab": "^4.0.0-alpha.60"

And here is where I get the error I mentioned on the top.这是我在顶部提到的错误的地方。

Any idea why this happens?知道为什么会这样吗?

It is because your @material-ui/lab is the latest version but the core is not the latest one.这是因为您的@material-ui/lab是最新版本,但核心不是最新版本。 Upgrading @material-ui/core to 4.12.1 (or latest ) version would solve this error.@material-ui/core升级到 4.12.1(或latest )版本可以解决这个错误。

I had the same issue with the Skeleton component.我对 Skeleton 组件有同样的问题。 I upgraded @material-ui/core to 4.12.1 and the error was resolved.我将@material-ui/core升级到4.12.1 ,错误解决了。

I had the same issue with Buttons, I upgraded my libraries to the next versions then run npm i , restart the server and it works.我对 Buttons 有同样的问题,我将我的库升级到下一个版本然后运行npm i ,重新启动服务器并且它工作。

@material-ui/core: "4.11.4"
@material-ui/lab: "4.0.0-alpha.58"
@material-ui/icons: "4.11.2"
@material-ui/pickers: "3.3.10"

暂无
暂无

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

相关问题 尝试导入错误:“alpha”未从“@material-ui/core/styles”导出 - Attempted import error: 'alpha' is not exported from '@material-ui/core/styles' 尝试导入错误:“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/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/ material-ui 'createSvgIcon' 未从 '@material-ui/core/utils' 导出 - material-ui 'createSvgIcon' is not exported from '@material-ui/core/utils' 如何对齐 Material-UI 骨架和响应? - How to align Material-UI Skeleton and responsive? 尝试导入错误:“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')
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM