[英]Module not found: Can't resolve '@material-ui/core/Container'
[英]How to solve Module not found: Can't resolve '@babel/runtime/core-js/map' in Material-UI
我正在為 React 使用 Material UI,我將 Material-UI 更新到最新版本,但它給了我以下錯誤
../node_modules/material-ui/styles/withStyles.js
找不到模塊:無法解析“@babel/runtime/core-js/map”
'C:\\Users\\User\\Documents\\code\\react\\node_modules\\material-ui\\styles'
我也降級到以前版本的 Material-UI,也安裝了正確版本的 babel,但仍然有同樣的問題。
這是我的 package.json
"dependencies": {
"@babel/runtime": "^7.4.0",
"@material-ui/core": "^4.1.3",
"@material-ui/icons": "^3.0.2",
"@material-ui/lab": "^3.0.0-alpha.30",
"axios": "^0.18.1",
"bootstrap": "^4.3.1",
"material-auto-rotating-carousel": "^3.0.1",
"material-auto-rotating-carousel-refurb": "^1.0.1",
"react": "^16.8.6",
"react-animated-slider": "^1.1.4",
"react-bootstrap": "^0.32.4",
"react-dom": "^16.8.6",
"react-motion": "^0.5.2",
"react-responsive-carousel": "^3.1.49",
"react-router": "^3.2.3",
"react-scripts": "2.1.2",
"react-slick": "^0.23.2",
"react-swipeable-views": "^0.13.3",
"react-tap-event-plugin": "^1.0.0",
"slick-carousel": "^1.8.1"
}
我通過在我的package.json
添加一個分辨率來解決這個問題,但它只有在你使用yarn
而不是npm
時才有效。
我的修復(如果你使用紗線)
// in your package.json
...
"resolutions": {
"material-ui/@babel/runtime": "7.0.0-beta.42"
}
...
為什么它有效?,因為@babel/runtime": "7.0.0-beta.42
仍然需要core-js
作為依賴,具體來說它需要core-js ^2.5.3
替代修復
如果您不使用yarn
而是npm
,您可以添加@babel/runtime": "7.0.0-beta.42
作為 devDependency,它也應該可以正常工作。
我留下了yarn resolutions
的鏈接,因為它可能對你很有趣。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.