我试图在react-native上添加一个路由器react native navigation v2到这个启动项目,但我有一个与 babel 包有关的问题(可能)。当我跑
react-native run-android
我在 Metro Bundler 中有这个错误:
加载依赖图,完成。: 捆绑失败: 错误: [BABEL] D:\react—native\projecti\index.js: .overr ides is not allowed in preset options
在 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在 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) 在 loadPresetDescriptor (D:\react-native\projecti\node_modules\metro\node_mo Iules\ftabel\core\lib\config\full.js:233:45) 在 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)
在控制台中构建成功结束。
我的 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"
]
}