首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >react本机-git-升级“错误:需要Babel "^7.0.0-0",但在从0.57.4升级到0.57.8时加载了"6.26.3”

react本机-git-升级“错误:需要Babel "^7.0.0-0",但在从0.57.4升级到0.57.8时加载了"6.26.3”
EN

Stack Overflow用户
提问于 2019-01-03 14:48:39
回答 2查看 968关注 0票数 1

我希望使用react-native-git-upgrade.将react本机从0.57.4升级到0.57.8

当我运行命令react-native-git-upgrade时,我得到以下错误:Requires Babel "^7.0.0-0", but was loaded with "6.26.3".

这是一个完整的错误堆栈:

代码语言:javascript
复制
git-upgrade ERR! An error occurred during upgrade:
git-upgrade ERR! 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'tmention "@babel/core" or "babel-core" to see what is calling Babel.
    at throwVersionError (/Users/franciscosarmento/Dev/peeq/peeqDaycare/node_modules/@babel/helper-plugin-utils/lib/index.js:65:11)
    at Object.assertVersion (/Users/franciscosarmento/Dev/peeq/peeqDaycare/node_modules/@babel/helper-plugin-utils/lib/index.js:13:11)
    at _default (/Users/franciscosarmento/Dev/peeq/peeqDaycare/node_modules/@babel/plugin-proposal-decorators/lib/index.js:35:7)
    at /Users/franciscosarmento/Dev/peeq/peeqDaycare/node_modules/@babel/helper-plugin-utils/lib/index.js:19:12
    at Function.memoisePluginContainer (/usr/local/lib/node_modules/react-native-git-upgrade/node_modules/babel-core/lib/transformation/file/options/option-manager.js:113:13)
    at Function.normalisePlugin (/usr/local/lib/node_modules/react-native-git-upgrade/node_modules/babel-core/lib/transformation/file/options/option-manager.js:146:32)
    at /usr/local/lib/node_modules/react-native-git-upgrade/node_modules/babel-core/lib/transformation/file/options/option-manager.js:184:30
    at Array.map (<anonymous>)
    at Function.normalisePlugins (/usr/local/lib/node_modules/react-native-git-upgrade/node_modules/babel-core/lib/transformation/file/options/option-manager.js:158:20)
    at OptionManager.mergeOptions (/usr/local/lib/node_modules/react-native-git-upgrade/node_modules/babel-core/lib/transformation/file/options/option-manager.js:234:36)
    at OptionManager.init (/usr/local/lib/node_modules/react-native-git-upgrade/node_modules/babel-core/lib/transformation/file/options/option-manager.js:368:12)
    at compile (/usr/local/lib/node_modules/react-native-git-upgrade/node_modules/babel-register/lib/node.js:103:45)
    at loader (/usr/local/lib/node_modules/react-native-git-upgrade/node_modules/babel-register/lib/node.js:144:14)
    at Object.require.extensions.(anonymous function) [as .js] (/usr/local/lib/node_modules/react-native-git-upgrade/node_modules/babel-register/lib/node.js:154:7)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at runCopyAndReplace (/usr/local/lib/node_modules/react-native-git-upgrade/cliEntry.js:164:41)
    at generateTemplates (/usr/local/lib/node_modules/react-native-git-upgrade/cliEntry.js:151:12)
    at Object.<anonymous> (/usr/local/lib/node_modules/react-native-git-upgrade/cliEntry.js:288:11)
    at Generator.next (<anonymous>)
    at step (/usr/local/lib/node_modules/react-native-git-upgrade/cliEntry.js:171:191)
    at /usr/local/lib/node_modules/react-native-git-upgrade/cliEntry.js:171:361
git-upgrade ERR! Restore initial sources

这是我的package.json

代码语言:javascript
复制
"dependencies": {
    "@babel/runtime": "7.0.0",
    "jsc-android": "224109.x.x",
    "prop-types": "^15.6.1",
    "react": "16.6.0-alpha.8af6728",
    "react-native": "0.57.4",
     ...
  },
  "devDependencies": {
    "@babel/core": "7.0.0",
    "@babel/plugin-proposal-class-properties": "7.0.0",
    "@babel/plugin-proposal-decorators": "7.0.0",
    "@babel/plugin-transform-flow-strip-types": "7.0.0",
    "@babel/preset-flow": "7.0.0",
    "babel-core": "^7.0.0-bridge.0",
    "babel-eslint": "^8.2.3",
    "babel-jest": "^23.6.0",
    "babel-plugin-transform-remove-console": "^6.9.4",
    "enzyme": "^3.5.0",
    "enzyme-adapter-react-16": "^1.3.1",
    "enzyme-to-json": "^3.3.4",
    "eslint": "^5.4.0",
    "eslint-config-airbnb": "^17.1.0",
    "eslint-config-prettier": "^3.0.1",
    "eslint-plugin-flowtype": "^2.50.0",
    "eslint-plugin-import": "^2.14.0",
    "eslint-plugin-jsx-a11y": "^6.1.1",
    "eslint-plugin-prettier": "^2.6.2",
    "eslint-plugin-react": "^7.11.1",
    "flow-bin": "0.78.0",
    "husky": "^0.14.3",
    "jest": "23.6.0",
    "lint-staged": "^7.1.0",
    "metro-react-native-babel-preset": "0.46.0",
    "prettier": "^1.14.2",
    "react-dom": "^16.3.2",
    "react-test-renderer": "16.6.0-alpha.8af6728",
    "regenerator-runtime": "^0.12.1"
  },

我已经尝试过将"resolutions": { "babel-core": "^7.0.0-bridge" }添加到package.json中,并安装了@babel/yarn add @babel/register --dev (yarn add @babel/register --dev),但是仍然会出现相同的错误。

有人能帮我解决这个错误吗?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2019-01-25 12:43:19

经过大量的研究,我找到了这里的解决方案。

删除.babelrc中的所有内容(将文件留给{})解决了这个问题。

票数 4
EN

Stack Overflow用户

发布于 2019-01-03 15:31:05

确保您使用的是'^7.0.0‘而不是'7.0.0’,这是完全匹配的。插件-建议-装饰模块是您的跟踪,给您的错误是7.2.3到今天。

查看倾斜与斜交的差异

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54024611

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档