Francisco Sarmento
Francisco Sarmento

Reputation: 408

react-native-git-upgrade "Error: Requires Babel "^7.0.0-0", but was loaded with "6.26.3" when upgrading from 0.57.4 to 0.57.8

I want to upgrade react-native from version 0.57.4 to 0.57.8 using react-native-git-upgrade.

When I run the command react-native-git-upgrade, I get the following error: Requires Babel "^7.0.0-0", but was loaded with "6.26.3".

This is the full error stack:

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

This is my 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"
  },

I already tried adding "resolutions": { "babel-core": "^7.0.0-bridge" } to package.json and installing @babel/register (yarn add @babel/register --dev) but I still get the same error.

Can anyone help me to solve this error?

Upvotes: 1

Views: 1018

Answers (2)

Francisco Sarmento
Francisco Sarmento

Reputation: 408

After a lot of research, I found the solution here.

Removing everything inside .babelrc (leave the file with {}) solved the problem.

Upvotes: 4

Saeed D.
Saeed D.

Reputation: 1176

Make sure you use '^7.0.0' and not '7.0.0' that is exact match. The plugin-proposal-decorators module is your trace that is giving you errors is on 7.2.3 as of today.

Check out difference between tilde and caret

Upvotes: 0

Related Questions