Babel overrides is not allowed in preset options react native navigation

≯℡__Kan透↙ 提交于 2019-12-05 18:01:20

It seems that you have RN 0.56 which used some beta versions of babel.

I see you have 2 solutions:

1) Keep RN 0.56 and set correct babel deps

For RN 0.56 you need to ensure all the @babel/* deps are fixed at version 7.0.0-beta.47 (Please see the change log of 0.56 for those)

2) Upgrade your project to RN 0.57

To be able to use latest babel 7 dependencies you will have to migrate your project to RN 0.57.

This is what I have for a 0.57.1 project:

"dependencies": {
    "react": "16.5.0",
    "react-native": "0.57.1",
    .......
  }

  "devDependencies": {
    "@babel/core": "^7.0.0",
    "@babel/plugin-proposal-class-properties": "^7.0.0",
    "@babel/plugin-proposal-decorators": "^7.0.0",
    "@babel/plugin-proposal-do-expressions": "^7.0.0",
    "@babel/plugin-proposal-export-default-from": "^7.0.0",
    "@babel/plugin-proposal-export-namespace-from": "^7.0.0",
    "@babel/plugin-proposal-function-bind": "^7.0.0",
    "@babel/plugin-proposal-function-sent": "^7.0.0",
    "@babel/plugin-proposal-json-strings": "^7.0.0",
    "@babel/plugin-proposal-logical-assignment-operators": "^7.0.0",
    "@babel/plugin-proposal-nullish-coalescing-operator": "^7.0.0",
    "@babel/plugin-proposal-numeric-separator": "^7.0.0",
    "@babel/plugin-proposal-object-rest-spread": "^7.0.0",
    "@babel/plugin-proposal-optional-chaining": "^7.0.0",
    "@babel/plugin-proposal-pipeline-operator": "^7.0.0",
    "@babel/plugin-proposal-throw-expressions": "^7.0.0",
    "@babel/plugin-syntax-dynamic-import": "^7.0.0",
    "@babel/plugin-syntax-import-meta": "^7.0.0",
    "@babel/plugin-syntax-object-rest-spread": "^7.0.0",
    "@babel/plugin-transform-runtime": "^7.0.0",
    "@babel/preset-env": "^7.0.0",
    "@babel/preset-flow": "^7.0.0",
    "@babel/register": "^7.0.0",
    "babel-core": "^7.0.0-bridge.0",
    "babel-preset-react-native-stage-0": "^1.0.1",
    .....

}

Important: update .babelrc configuration to:

{
    "presets": ["module:metro-react-native-babel-preset"]
}

More info about RN 0.56, 0.57 change log here:

https://github.com/react-native-community/react-native-releases/blob/master/CHANGELOG.md

More info about babel 7 deps here:

https://new.babeljs.io/docs/en/next/v7-migration.html#versioning-dependencies-blog-2017-12-27-nearing-the-70-releasehtml-peer-dependencies-integrations https://github.com/babel/babel-upgrade

More info about upgrading a RN project to babel 7 here:

React native upgrade from babel 6 to babel 7

Note: make sure you remove all node_modules and re-install them and clean local cache after babel versions modifications.

rm -rf $TMPDIR/react-*; rm -rf $TMPDIR/haste-*; rm -rf $TMPDIR/metro-*; watchman watch-del-all

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!