我正在构建一个 React Native 应用程序,我遇到了以下问题:包@react-native-picker/picker
被两个不同的节点模块包含。因此,我遇到了错误:
tried to register two views with the same name RNCPicker
.
我曾尝试在指定的应用程序中使用块"resolutions"
,但它没有帮助。纱线为什么显示以下内容:package.json
@react-native-picker/picker
yarn why v1.22.5
[1/4] Why do we have the module "@react-native-picker/picker"...?
[2/4] Initialising dependency graph...
[3/4] Finding dependency...
[4/4] Calculating file sizes...
=> Found "@react-native-picker/picker@1.12.0"
info Reasons this module exists
- "native-base" depends on it
- Hoisted from "native-base#@react-native-picker#picker"
- Hoisted from "component-library#react-native-picker-select#@react-native-picker#picker"
info Disk size without dependencies: "488KB"
info Disk size with unique dependencies: "488KB"
info Disk size with transitive dependencies: "488KB"
info Number of shared dependencies: 0
组件库包是我自己的,其中包含一个导入react-native-picker-select
. 注释掉导入解决了“两个视图”错误,但这显然不是一个修复。
解决此问题的正确方法是什么?在我看来,依赖关系应该在两个节点模块之间共享,所以只有一个被注册?这不就是吊装应该发生的事情吗?
在组件库节点模块中更新react-native-picker-select
到最新版本 ( ) 后出现错误。8.0.4
最新版本切换到使用@react-native-picker/picker
.
编辑:我有解决该问题的方法,但这仍然不是正确的解决方法。包括@react-native-picker/picker
在应用程序中package.json
并手动删除node_modules/component-library/node_modules/@react-native-picker/picker
至少会使错误消失并且应用程序再次运行,并使用工作react-native-picker-select
组件。