代码之家  ›  专栏  ›  技术社区  ›  Ray Jonathan

需要Babel“7.0.0-0”,但加载了“6.26.3”

  •  18
  • Ray Jonathan  · 技术社区  · 6 年前

    继续得到这个错误,无论我尝试安装(巴别塔明智),因为我遵循其他类似的报告。这是堆栈跟踪:

    error: bundling failed: 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. (While processing preset:
    "C:\\Users\\Admin-ESS\\Absent\\node_modules\\@babel\\preset-env\\lib\\index.js")
        at throwVersionError (C:\Users\Admin-ESS\Absent\node_modules\@babel\preset-env\node_modules\@babel\helper-plugin-utils\lib\index.js:65:11)
        at Object.assertVersion (C:\Users\Admin-ESS\Absent\node_modules\@babel\preset-env\node_modules\@babel\helper-plugin-utils\lib\index.js:13:11)
        at _default (C:\Users\Admin-ESS\Absent\node_modules\@babel\preset-env\lib\index.js:150:7)
        at C:\Users\Admin-ESS\Absent\node_modules\@babel\preset-env\node_modules\@babel\helper-plugin-utils\lib\index.js:19:12
        at C:\Users\Admin-ESS\Absent\node_modules\metro\node_modules\babel-core\lib\transformation\file\options\option-manager.js:317:46
        at Array.map (<anonymous>)
        at OptionManager.resolvePresets (C:\Users\Admin-ESS\Absent\node_modules\metro\node_modules\babel-core\lib\transformation\file\options\option-manager.js:275:20)
        at OptionManager.mergePresets (C:\Users\Admin-ESS\Absent\node_modules\metro\node_modules\babel-core\lib\transformation\file\options\option-manager.js:264:10)
        at OptionManager.mergeOptions (C:\Users\Admin-ESS\Absent\node_modules\metro\node_modules\babel-core\lib\transformation\file\options\option-manager.js:249:14)
        at OptionManager.init (C:\Users\Admin-ESS\Absent\node_modules\metro\node_modules\babel-core\lib\transformation\file\options\option-manager.js:368:12)
        at File.initOptions (C:\Users\Admin-ESS\Absent\node_modules\metro\node_modules\babel-core\lib\transformation\file\index.js:212:65)
        at new File (C:\Users\Admin-ESS\Absent\node_modules\metro\node_modules\babel-core\lib\transformation\file\index.js:135:24)
        at Pipeline.transform (C:\Users\Admin-ESS\Absent\node_modules\metro\node_modules\babel-core\lib\transformation\pipeline.js:46:16)
        at Object.transform (C:\Users\Admin-ESS\Absent\node_modules\metro\src\transformer.js:135:5)
        at Object.transformCode [as transform] (C:\Users\Admin-ESS\Absent\node_modules\metro\src\JSTransformer\worker\index.js:253:15)
        at execMethod (C:\Users\Admin-ESS\Absent\node_modules\jest-worker\build\child.js:92:29)
        at process.on (C:\Users\Admin-ESS\Absent\node_modules\jest-worker\build\child.js:42:7)
        at process.emit (events.js:180:13)
        at emit (internal/child_process.js:783:12)
    

    {
      "name": "Absent",
      "version": "0.1.0",
      "private": true,
      "devDependencies": {
        "babel-preset-react-native-stage-0": "^1.0.1",
        "jest": "^23.5.0",
        "jest-react-native": "^18.0.0",
        "react-test-renderer": "16.3.1"
      },
      "scripts": {
        "start": "react-native start",
        "android": "react-native run-android",
        "ios": "react-native run-ios",
        "test": "jest"
      },
      "jest": {
        "preset": "react-native"
      },
      "dependencies": {
        "@babel/core": "^7.0.0-rc.1",
        "@babel/preset-env": "^7.0.0-rc.1",
        "@babel/preset-react": "^7.0.0-rc.1",
        "jail-monkey": "^1.0.0",
        "prop-types": "^15.6.2",
        "react": "16.3.1",
        "react-native": "^0.55.4",
        "react-native-device-info": "^0.22.4",
        "react-native-elements": "^0.19.1",
        "react-native-firebase": "^4.3.8",
        "react-native-modal": "^6.5.0",
        "react-native-router-flux": "^4.0.1",
        "react-native-size-matters": "^0.1.2",
        "react-native-vector-icons": "^5.0.0",
        "react-redux": "^5.0.7",
        "redux": "^4.0.0",
        "redux-thunk": "^2.3.0"
      },
      "rnpm": {
        "assets": [
          "./assets/fonts/"
        ]
      }
    }
    

    如果你能给我点建议,我将不胜感激。。。

    4 回复  |  直到 6 年前
        1
  •  26
  •   kmdreko    6 年前

    看来你需要安装 babel-core 如文件所示: https://jestjs.io/docs/en/getting-started#using-babel

    yarn add --dev babel-jest babel-core@^7.0.0-bridge.0 @babel/core regenerator-runtime

        2
  •  18
  •   Yoruba    5 年前

    babel -V
    

    如果不是verion 7或更高版本

    npm uninstall babel-cli -g
    npm uninstall babel-core -g
    

    以及

    npm install @babel/cli -g
    npm install @babel/core -g
    

    如果你在开玩笑

    npm install babel-core@7.0.0-bridge.0 --save-dev
    

        3
  •  6
  •   Darryl RN    6 年前

    我在网上找到的解决方案都不管用,我按以下方式解决了问题:

    1. 删除 jest @babel/core babel-core v7桥)
    2. npm安装
    3. npm install jest@babel/core——保存dev
        4
  •  6
  •   Idan Gozlan    5 年前

        5
  •  1
  •   noone    4 年前

    有时是因为你已经安装了 babel cli和babel/cli ,或 它会引起冲突

    1) 删除节点模块

    2) 从包中删除babel cli,babel core.json,保留@babel/core,@babel/cli

    巴别尔克利

    牙髓