I trying to add a router react native navigation v2 to this starter project on react-native, but I have a problem that is connected with babel package (probably). When I run
react-native run-android
I have this error in Metro Bundler:
loading dependency graph, done. : bundling failed: Error: [BABEL] D:\react—native\projecti\index.js: .overr ides is not allowed in preset options
at Object.keys.forEach.key (D:\react—native\projecti\node_modules\metro\node odules\Obabel\core\lib\config\validation\options.js:71:13) at Array.forEach () at validate (D:\react—native\projecti\node_modules\metro\node_modules\nabel core\lib\config\validation\options.js:69:21) at instantiatePreset (D:\react—native\projecti\node_modules\metro\node_modul s\l@babel\core\lib\config\full.js:242:36) at cachedFunction (D:\react—native\projecti\node_modules\metro\node_modules\ babel\core\lib\config\caching.js:42:19) at loadPresetDescriptor (D:\react—native\projecti\node_modules\metro\node_mo Iules\ftabel\core\lib\config\full.js:233:45) at config.presets.map.descriptor (D:\react—native\projecti\node_modules\metr I\node_modules\ftabel\core\lib\config\full.js:68:19) at Array.map () at recurseDescriptors (D:\react—native\projecti\node_modules\metro\node_modu les\Obabel\core\lib\config\full.js:66:38)
Building in console ended successfully.
My package.json
{
"name": "project1",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest",
"android": "cd ./android && ./gradlew app:assembleDebug && ./gradlew installDebug"
},
"dependencies": {
"@babel/runtime": "^7.1.2",
"react": "16.5.0",
"react-native": "0.56",
"react-native-navigation": "^2.0.2569"
},
"devDependencies": {
"@babel/core": "^7.1.0",
"@babel/preset-env": "^7.1.0",
"babel-eslint": "^9.0.0",
"babel-jest": "^23",
"babel-preset-react-native": "^5",
"jest": "23.6.0",
"metro-react-native-babel-preset": "0.47.0",
"react-test-renderer": "16.5.0"
},
"jest": {
"preset": "react-native"
}
}
.babelrc
{
"presets": [
"@babel/preset-env",
"module:metro-react-native-babel-preset"
]
}
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.
Important: update
.babelrc
configuration to: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