Dejan
Dejan

Reputation: 317

How to fix Module build failed - Uncaught Error: Module build failed (from ./node_modules/babel-loader/lib/index.js):

Can anyone help me with this?

Also

TypeError: /Users/.../assets/js/theme/global/quick-search.js: Cannot read property 'has' of undefined
    at resolvePath (/Users/.../node_modules/babel-plugin-lodash/lib/importModule.js:22:24)
 

I have upgraded and follow this https://github.com/babel/babel-upgrade. I just downloaded project and wanna start it locally but this error is really frustrating. I tried bunch of things, I saw that many people have same problem.

Here is my package.json

"devDependencies": {
    "@babel/cli": "^7.12.8",
    "@babel/core": "^7.12.9",
    "@babel/node": "^7.12.6",
    "@babel/plugin-proposal-class-properties": "^7.0.0",
    "@babel/plugin-syntax-dynamic-import": "^7.0.0",
    "@babel/plugin-transform-regenerator": "^7.0.0",
    "@babel/plugin-transform-runtime": "^7.0.0",
    "@babel/polyfill": "^7.12.1",
    "@babel/preset-env": "^7.12.7",
    "@babel/preset-react": "^7.12.7",
    "@babel/register": "^7.12.1",
    "@bigcommerce/citadel": "~2.15.1",
    "babel-core": "^7.0.0-bridge.0",
    "babel-eslint": "^9.0.0",
    "babel-jest": "^23.4.2",
    "babel-loader": "^8.2.2",
    "babel-plugin-dynamic-import-webpack": "~1.0.2",
    "babel-plugin-lodash": "~3.3.2",
    "clean-webpack-plugin": "~0.1.19",
    "css-loader": "~2.1.1",
    "eslint": "^4.8.0",
    "eslint-config-airbnb": "~16.0.0",
    "eslint-plugin-import": "~2.7.0",
    "eslint-plugin-jsx-a11y": "~6.0.2",
    "eslint-plugin-react": "^7.12.4",
    "grunt": "^1.0.1",
    "grunt-cli": "^1.3.2",
    "grunt-eslint": "^20.0.0",
    "grunt-karma": "^3.0.1",
    "grunt-scss-lint": "^0.5.0",
    "grunt-svgstore": "^2.0.0",
    "imports-loader": "~0.7.1",
    "jasmine-core": "~2.2.0",
    "jest": "^26.6.3",
    "jquery-mask-plugin": "~1.14.15",
    "karma": "^4.0.1",
    "karma-babel-preprocessor": "^7.0.0",
    "karma-coverage": "^1.1.1",
    "karma-es6-shim": "^1.0.0",
    "karma-jasmine": "^1.1.0",
    "karma-phantomjs-launcher": "^1.0.4",
    "karma-sourcemap-loader": "0.3.7",
    "karma-verbose-reporter": "0.0.6",
    "karma-webpack": "^2.0.4",
    "lighthouse": "^4.0.0-alpha.2-3.2.1",
    "load-grunt-config": "~1.0.1",
    "lodash-webpack-plugin": "~0.11.2",
    "mdbreact": "~4.11.1",
    "npx": "~10.2.0",
    "react-google-recaptcha": "~1.0.5",
    "react-inputs-validation": "~2.2.0",
    "react-markdown": "~4.0.6",
    "regenerator-runtime": "^0.13.7",
    "sass-loader": "~7.1.0",
    "style-loader": "~0.23.1",
    "time-grunt": "~1.2.2",
    "webpack": "^4.44.2",
    "webpack-bundle-analyzer": "~3.0.3",
    "webpack-cli": "~3.1.2",
    "webpack-merge": "~4.1.2"
  },

Maybe because I have these two dep. "@babel/core": "^7.12.9", and "babel-core": "^7.0.0-bridge.0". I tried to dellete babel-core but when i want to start project it says that babel-loader needs babel-core. Any help would be nice, thanks!

Upvotes: 0

Views: 259

Answers (1)

Heather Barr
Heather Barr

Reputation: 362

Since Babel 7 the Babel team switched to scoped packages, so you now have to use @babel/core instead of babel-core. But in essence, @babel/core is just a newer version of babel-core. This is done to make a better distinction which packages are official and which are third-party. -source

I think you’re on the right track with deleting/uninstalling the babel-core dependency, it may just need a little more tweaking to get going. In the babel upgrade doc you shared, it looks like these modifications need to be made to your devDependencies :

enter image description here

In their preview, they’ve removed the babel-loader “6.0.0” and added in babel-loader “v8.0.0-beta.0”. Some of your other dependencies show different versions than in the readMe. Have you tested by switching these one out, running npm i and then npm start?

One of our developers had a similar problem and resolved this by running the npm update command!

Upvotes: 1

Related Questions