【发布时间】:2018-10-03 17:34:03
【问题描述】:
我试图在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) 在 Array.forEach () 验证时(D:\react—native\projecti\node_modules\metro\node_modules\nabel core\lib\config\validation\options.js:69:21) 在 instantiatePreset (D:\react—native\projecti\node_modules\metro\node_modul s\l@babel\core\lib\config\full.js:242:36) 在 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) 在 Array.map() 在 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"
]
}
【问题讨论】:
-
这个问题你解决了吗?我遇到了同样的错误。
-
不,我没有。我想尝试在 Linux 上做同样的事情
标签: react-native react-native-navigation wix-react-native-navigation react-native-navigation-v2