3

Whenever, I run the program, I get this error:

ERROR in ./index.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
Error: Requires Babel "^7.0.0-0", but was loaded with "6.26.3". 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.
    at throwVersionError (E:\ReactJS final\node_modules\@babel\helper-plugin-utils\lib\index.js:65:11)
    at Object.assertVersion (E:\ReactJS final\node_modules\@babel\helper-plugin-utils\lib\index.js:13:11)
    at _default (E:\ReactJS final\node_modules\@babel\plugin-proposal-object-rest-spread\lib\index.js:51:7)
    at E:\ReactJS final\node_modules\@babel\helper-plugin-utils\lib\index.js:19:12
    at Function.memoisePluginContainer (E:\ReactJS final\node_modules\babel-core\lib\transformation\file\options\option-manager.js:113:13)
    at Function.normalisePlugin (E:\ReactJS final\node_modules\babel-core\lib\transformation\file\options\option-manager.js:146:32)
    at E:\ReactJS final\node_modules\babel-core\lib\transformation\file\options\option-manager.js:184:30
    at Array.map (<anonymous>)
    at Function.normalisePlugins (E:\ReactJS final\node_modules\babel-core\lib\transformation\file\options\option-manager.js:158:20)
    at OptionManager.mergeOptions (E:\ReactJS final\node_modules\babel-core\lib\transformation\file\options\option-manager.js:234:36)
    at OptionManager.init (E:\ReactJS final\node_modules\babel-core\lib\transformation\file\options\option-manager.js:368:12)
    at File.initOptions (E:\ReactJS final\node_modules\babel-core\lib\transformation\file\index.js:212:65)
    at new File (E:\ReactJS final\node_modules\babel-core\lib\transformation\file\index.js:135:24)
    at Pipeline.transform (E:\ReactJS final\node_modules\babel-core\lib\transformation\pipeline.js:46:16)
    at transpile (E:\ReactJS final\node_modules\babel-loader\lib\index.js:50:20)
    at Object.module.exports (E:\ReactJS final\node_modules\babel-loader\lib\index.js:173:20)
i 「wdm」: Failed to compile. 

Please help me to solve this problem. (I also have attached the package.json file here)

{
  "name": "reactjs-final",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "it": "webpack-dev-server --hot"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "@babel/plugin-proposal-object-rest-spread": "^7.5.1",
    "@babel/preset-env": "^7.5.4",
    "babel-loader": "^7.1.5",
    "babel-preset-stage-0": "^6.24.1",
    "babel-preset-stage-3": "^6.24.1",
    "webpack": "^4.33.0",
    "webpack-cli": "^3.3.3",
    "webpack-dev-server": "^3.7.0"
  },
  "dependencies": {
    "@babel/cli": "^7.5.0",
    "@babel/core": "^7.5.4",
    "@deck.gl/core": "^7.0.0",
    "@deck.gl/mapbox": "^7.1.4",
    "@fortawesome/fontawesome-free": "^5.9.0",
    "@mapbox/mapbox-gl-geocoder": "^4.4.0",
    "@mapbox/mapbox-sdk": "^0.6.0",
    "@mapbox/react-geocoder": "^2.5.0",
    "axios": "^0.19.0",
    "babel-core": "^6.26.3",
    "babel-install": "^2.1.0",
    "babel-preset-env": "^1.7.0",
    "babel-preset-react": "^6.24.1",
    "debounce": "^1.2.0",
    "deck.gl": "^7.1.4",
    "dotenv": "^8.0.0",
    "formik": "^1.5.7",
    "http-proxy-middleware": "^0.19.1",
    "install-peers": "^1.0.3",
    "mapbox-gl": "^0.47.0",
    "npm-autoinstaller": "^1.3.1",
    "randomcolor": "^0.5.4",
    "raw-loader": "^3.0.0",
    "react": "^16.8.6",
    "react-autocomplete": "^1.8.1",
    "react-dom": "^16.8.6",
    "react-geocoder-mapbox": "^2.5.12",
    "react-google-recaptcha": "^1.0.5",
    "react-helmet": "^5.2.1",
    "react-loading-skeleton": "^1.1.2",
    "react-map-gl": "^5.0.3",
    "react-map-gl-geocoder": "^2.0.5",
    "react-mapbox-gl-geocoder": "^1.0.3",
    "react-modal": "^3.8.2",
    "react-redux": "^7.1.0",
    "react-router-dom": "^5.0.1",
    "react-router-ga": "^1.2.0",
    "react-router-hash-link": "^1.2.1",
    "react-scripts": "^3.0.1",
    "react-text-loop": "^2.0.2",
    "redux": "^4.0.1",
    "redux-thunk": "^2.3.0",
    "uikit": "^3.1.6"
  }
}
loganfsmyth
  • 156,129
  • 30
  • 331
  • 251
Sagar
  • 31
  • 1
  • 3

3 Answers3

2

You may need the babel 7 bridge as version for babel-core

"babel-core": "^7.0.0-bridge.0"

in your package.json

You can check package-lock.json and see what version of babel-core is being installed there. If it's still installing 6.26.3, you may have another package that is requiring that specific version that should be updates as well. In my case it was jest as well as babelify to the latest versions support babel 7 to stop it from installing the older babel version in my package-lock.json. It does also sound like you do need to update your version of babel-loader from that error message as well.

kckaiwei
  • 416
  • 7
  • 18
0

In your package.json you have this two packages.

{
    "@babel/core": "^7.5.4",
    ...
    "babel-core": "^6.26.3",
}

They are the same package but the last one is a prior version.

Edit:

You also need to update babel-loader

"babel-loader": "^8.0.6" will work.

Vencovsky
  • 28,550
  • 17
  • 109
  • 176
  • Now, this error is occuring: ERROR in ./index.js Module build failed (from ./node_modules/babel-loader/lib/index.js): Error: Cannot find module 'babel-core' – Sagar Jul 11 '19 at 14:00
  • @Sagar have you runned `npm i` after removing it? Also check the link I added that explains about `@babel/core` and `babel-core` – Vencovsky Jul 11 '19 at 19:24
0

It worked for me when I actually changed babel-cli to the version 7, so maybe the problem is there

kony
  • 92
  • 6