Webpack failed to compile error. babel-core version issue

632 Views Asked by At

I am trying to run react project. It gives error on compilation:

Module build failed: Error: Requires Babel "^7.0.0-0", but was loaded with "6.25.0". If you are sure you have a compatible version of @babel/core, it is likely that something in your build process is loading the wrong version

Inspect the stack trace of this error to look for the first entry that doesn't mention "@babel/core" or "babel-core" to see what is calling Babel.

Currently this is my package.json:

"dependencies": {

"@babel/core": "^7.11.1",
"@babel/plugin-proposal-class-properties": "^7.10.4",
"@babel/plugin-proposal-object-rest-spread": "^7.11.0",
"@babel/preset-env": "^7.11.0",
"@babel/preset-react": "^7.10.4",
"babel-cli": "6.24.1",
"babel-loader": "^7.1.1",

}

Following is the entry in webpack.config.js file:

module: {

rules: [{
  loader: 'babel-loader',
  test: /\.js$/,
  exclude: /node_modules/
}

I uninstalled babel-core v6.25.0 and installed @babel/core v7.10.4 but still getting same error. Is there any way to solve this issue?

1

There are 1 best solutions below

1
sabcan On
I had the same mistake. Installed the following versions fixed:

"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-preset-env": "^1.6.0",