当前位置: 首页 > 面试题库 >

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

太叔高义
2023-03-14
问题内容

无论我尝试安装什么(明智的做法),都应保持此错误,因为我遵循其他类似的报告。这是堆栈跟踪:

>     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)
>  

和我的package.json:



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

任何指针将不胜感激在这里…


问题答案:

看起来您需要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



 类似资料:
  • 本文向大家介绍为什么需要Babel JS?,包括了为什么需要Babel JS?的使用技巧和注意事项,需要的朋友参考一下 Babel是一个工具链,主要用于在当前和较旧的浏览器或环境中将ECMAScript 2015+代码转换为JavaScript的向后兼容版本。Babel的插件允许您立即使用新语法,而无需等待浏览器支持。 使用babel JS的主要原因是- 语法转换(最新的JS语法为向后兼容的语法。

  • 从 Babel v7 开始,所有针对处于标准提案阶段的功能所编写的预设(stage preset)都已被弃用。 请查看 此篇博客文章 了解更多信息。 有关升级说明,请参与 这份 README。 Install npm install --save-dev @babel/preset-stage-0 Usage Via .babelrc (Recommended) .babelrc { "pr

  • 我尝试了几种解决方案,但我无法让它们中的任何一个发挥作用。 这是我的代码:

  • 我正在使用以下代码: xlsx文件本身有25,000行,每行有500列的内容。在调试过程中,我看到我创建XSSFWorkbook的第三行,需要很多时间(1小时!)来完成这个语句。 有没有更好的方法来访问原始xlsx文件的值?

  • 问题内容: 我正在尝试将Webpack与Babel一起使用来编译ES6资产,但是却收到以下错误消息: 这是我的Webpack配置的样子: 这是利用Webpack的中间件步骤: 我所有的index.js文件正在做的事情是导入react,但是似乎“ babel-loader”无法正常工作。 我正在使用’babel-loader‘6.0.0。 问题答案: 您需要安装预设: 然后配置:

  • 出于性能的考虑,我们会对模块和组件进行按需加载。 按需加载组件 通过 umi/dynamic 接口实现,比如: import dynamic from 'umi/dynamic'; const delay = (timeout) => new Promise(resolve => setTimeout(resolve, timeout)); const App = dynamic({ loa