babel JS file can't resolve “@babel/runtime/helpers/builtin/classCallCheck”

后端 未结 4 1372
旧巷少年郎
旧巷少年郎 2020-12-04 01:19

on-rest my project was working great untill I delete my node_modules file and try to re-install npm package.

I am getting this error

./node_modules/         


        
相关标签:
4条回答
  • 2020-12-04 02:05

    Since Babel 7.x is still a beta version, there was a breaking change in beta.56, which was released yesterday.

    "@babel/runtime": "^7.0.0-beta.56",
    

    If you're using a beta version of something, it is dangerous to use ^ in your version number, because that means it will accept any recent version, whether or not it is actually compatible with previous beta versions.

    Since react-scripts uses https://github.com/facebook/create-react-app/blob/1407287839f94151cec729bd89441d4eee7d9dd3/packages/babel-preset-react-app/package.json#L28

    "@babel/plugin-transform-runtime": "7.0.0-beta.46",

    Your should likely have

    "@babel/runtime": "7.0.0-beta.46",
    

    in your own package.json to match.

    0 讨论(0)
  • 2020-12-04 02:08

    In my case the problem was in relative paths and complex project structure, so that I had to specify exact location of my node_modules directory:

    module.exports = {  
        resolve: {
          modules: [
            path.resolve(__dirname, "node_modules")
          ],
      ...
    
    0 讨论(0)
  • 2020-12-04 02:12

    If you want to use the 7.0.0-beta.56 version, the easiest solution is to create builtin/ folder manually inside helpers/ folder then, move or copy the contents of helpers folder inside helpers/builtin/ and you will not see this error message anymore.

    0 讨论(0)
  • 2020-12-04 02:16

    In case you are running into this because of your dependency on material-ui:

    Looks like material-ui updated its package.json to reference '7.0.0-beta.42' instead of '^7.0.0-beta.42'

    See Issue: 12409

    0 讨论(0)
提交回复
热议问题