我想使用 react-native-git-upgrade 将react-native从版本 0.57.4 升级到 0.57.8 。 / p>
运行命令react-native-git-upgrade
时,出现以下错误:Requires Babel "^7.0.0-0", but was loaded with "6.26.3".
这是完整的错误堆栈:
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
"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 / register(yarn add @babel/register --dev
),但仍然出现相同的错误。
有人可以帮助我解决此错误吗?
答案 0 :(得分:3)
经过大量研究,我找到了解决方法here。
删除.babelrc中的所有内容(用{}
保留文件)解决了这个问题。
答案 1 :(得分:0)
请确保使用完全匹配的“ ^ 7.0.0”而不是“ 7.0.0”。到目前为止,plugin-proposal-decorators模块是给您带来错误的跟踪,该错误从7.2.3开始。