最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to solve Module not found: Can't resolve '@babelruntimecore-jsmap' in Material-UI - Sta

programmeradmin5浏览0评论

I am using Material UI for React, I updated the Material-UI to the latest version and it is giving me following error

../node_modules/material-ui/styles/withStyles.js

Module not found: Can't resolve '@babel/runtime/core-js/map' in

'C:\Users\User\Documents\code\react\node_modules\material-ui\styles'

I downgraded to the previous version of the Material-UI as well, worked around with installing the correct version of babel as well but still having the same issue.

Here is my 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"
  }

I am using Material UI for React, I updated the Material-UI to the latest version and it is giving me following error

../node_modules/material-ui/styles/withStyles.js

Module not found: Can't resolve '@babel/runtime/core-js/map' in

'C:\Users\User\Documents\code\react\node_modules\material-ui\styles'

I downgraded to the previous version of the Material-UI as well, worked around with installing the correct version of babel as well but still having the same issue.

Here is my 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"
  }
Share Improve this question edited Jul 2, 2019 at 4:35 user3623843 asked Jul 2, 2019 at 4:05 user3623843user3623843 291 silver badge7 bronze badges 6
  • What is the stack trace of the error? You've left out the most important part. – loganfsmyth Commented Jul 2, 2019 at 4:28
  • The material-ui beta package is deprecated and buggy, hence the issue here. You should change to a stable version of @material-ui/core - github./babel/babel/issues/9026 – ravibagul91 Commented Jul 2, 2019 at 4:38
  • Yeah, your error mentions material-ui but your dependencies reference @material-ui/core so this question has mixed messages. If you're using material-ui them your deps are wrong, and you need to downgrade to a stable version. – loganfsmyth Commented Jul 2, 2019 at 4:49
  • @ravibagul91 I have followed this and only using material-ui/core not material-ui. You can see in my package.json dependencies as well – user3623843 Commented Jul 2, 2019 at 5:26
  • There must be something in your system still referencing material-ui or else the error message wouldn't be mentioning it. – loganfsmyth Commented Jul 2, 2019 at 5:43
 |  Show 1 more ment

1 Answer 1

Reset to default 5

I figured this issue out by adding a resolution in my package.json, but it only will work if you use yarn instead of npm.

my fix (if you use yarn)

// in your package.json
...
"resolutions": {
    "material-ui/@babel/runtime": "7.0.0-beta.42"
}
...

Why does it work?, because @babel/runtime": "7.0.0-beta.42 still requires core-js as a dependency, in specific it requires core-js ^2.5.3

Alternative fix

If you are not using yarn and rather npm, you can add @babel/runtime": "7.0.0-beta.42 as a devDependency and it should be work fine as well.

I left the link to yarn resolutions, because it might be interesting for you.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论