Требуется Babel «7.0.0-0», но загружен «6.26.3» - PullRequest
2 голосов
/ 11 июля 2019

Всякий раз, когда я запускаю программу, я получаю эту ошибку:

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. 

Пожалуйста, помогите мне решить эту проблему. (Я также прикрепил файл package.json здесь)

{
  "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"
  }
}

Ответы [ 2 ]

0 голосов
/ 11 июля 2019

Я согласен с @Vencovsky, что обновление "babel-core": "^6.26.3" до "@babel/core": "^7.5.4" будет работать.вам нужно всего лишь обновить строку импорта до @babel/core, где бы вы ее не использовали.

0 голосов
/ 11 июля 2019

В вашем package.json есть два пакета.

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

Это один и тот же пакет , но последний является предыдущей версией.

Редактировать:

Вам также нужно обновить babel-loader

"babel-loader": "^8.0.6" будет работать.

...