运行打包程序时React Native命名冲突错误,由“lodash”和“yeoman-generator”引起

时间:2016-11-30 11:30:36

标签: javascript npm react-native jestjs react-native-cli

描述

在我的项目中,我正在使用"react-native": "0.36.0"和依赖项之间:

  • "lodash": "^4.15.0"
  • "yeoman-generator": "^0.24.1"

"^3.10.1"使用高于"lodash"的版本而"0.21.2"使用"yeoman-generator"时,我会在"lodash""inquirer"和{{}上发出命名冲突1}}运行打包器时。

生殖

拥有上述依赖项并运行:"cli-width"

结果:

react-native start --reset-cache

解决方案

使用jest-haste-map: @providesModule naming collision: Duplicate module name: inquirer Paths: /CoolProject/node_modules/react-native/node_modules/yeoman-generator/node_modules/inquirer/package.json collides with /CoolProject/node_modules/react-native/node_modules/inquirer/package.json This warning is caused by a @providesModule declaration with the same name across two different files. jest-haste-map: @providesModule naming collision: Duplicate module name: lodash Paths: /CoolProject/node_modules/react-native/node_modules/lodash/package.json collides with /CoolProject/node_modules/react-native/node_modules/inquirer/node_modules/lodash/package.json This warning is caused by a @providesModule declaration with the same name across two different files. jest-haste-map: @providesModule naming collision: Duplicate module name: cli-width Paths: /CoolProject/node_modules/react-native/node_modules/yeoman-generator/node_modules/cli-width/package.json collides with /CoolProject/node_modules/react-native/node_modules/cli-width/package.json This warning is caused by a @providesModule declaration with the same name across two different files. "lodash"的相同版本作为"yeoman-generator"中使用的版本(即react-native@0.36.0 "^3.10.1""lodash" { {1}})修复了这个问题,但是现在改变它们并不是我的选择,特别是因为"0.21.2"是另一个依赖项的依赖项。 还有其他可能的解决办法吗?

谢谢!

更新

有关此问题的更多详细信息,请参阅我发布的"yeoman-generator" Gihub问题:https://github.com/facebook/react-native/issues/11200

更新2

"yeoman-generator"升级到0.39可以解决问题。实际修复似乎是删除了显然未使用的(可能已过时的)react-native依赖项:https://github.com/facebook/react-native/commit/1fd7a574ba538d05da4be841c84a70766464ec13

1 个答案:

答案 0 :(得分:0)

当您在安装模块或使用React Native设置项目时从npm切换到yarn时,通常会发生这种情况。简单npm install通常会关闭此问题,而不会损坏项目的配置。

npm install将通知您某些模块已弃用或与React Native版本不同的版本设置,并执行修复它所需的操作。此外,如果您希望真正清理配置,请注意npm WARN gentlyRm有关已放弃但未删除的软件包的警告。