[英]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.