3

描述

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

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

当使用高于"^3.10.1"for"lodash""0.21.2"for 的版本时,我会在和运行打包程序时"yeoman-generator"遇到命名冲突。"lodash""inquirer""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.

解决方案

使用与for"lodash"和for"yeoman-generator"中使用的版本相同的版本可以解决问题,但目前对我来说确实不是一个选择,特别是因为它是另一个依赖项的依赖项。还有其他可能的解决方法吗?react-native@0.36.0"^3.10.1""lodash""0.21.2""yeoman-generator""yeoman-generator"

谢谢!

更新

关于这个问题的更多细节可以在react-native我发布的 Gihub 问题中找到:https ://github.com/facebook/react-native/issues/11200

更新 2

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

4

1 回答 1

0

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

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

于 2017-08-11T15:03:51.057 回答