描述
在我的项目中,我使用"react-native": "0.36.0"并在依赖项中使用:
"lodash": "^4.15.0""yeoman-generator": "^0.24.1"当使用高于"^3.10.1"版本的"lodash"版本和"0.21.2"版本的"yeoman-generator"版本时,在运行packager时,会得到"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.解决方案
对"lodash"和"yeoman-generator"使用与react-native@0.36.0中使用的版本相同的版本(即用于"lodash"的"^3.10.1"版本和用于"yeoman-generator"的"0.21.2"版本)可以解决这个问题,但对我来说,更改它们确实不是一个选项,特别是因为"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。
发布于 2017-08-11 15:03:51
这通常发生在您从npm切换到yarn时,在安装模块或使用React设置项目时。一个简单的npm install通常会在不破坏项目配置的情况下解决这个问题。
npm install会通知您,您的一些模块要么被废弃,要么在与Reacti原住民版本不同的版本上设置,并做必要的事情来修复它。此外,如果您希望真正地清理您的配置,请注意有关已搁置但未删除的包的npm WARN gentlyRm警告。
https://stackoverflow.com/questions/40887249
复制相似问题