简体   繁体   English

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

[英]React Native naming collision error when running packager, caused by “lodash” and “yeoman-generator”

Description 描述

In my project I am using "react-native": "0.36.0" and among the dependencies: 在我的项目中,我使用"react-native": "0.36.0"和依赖项之间:

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

When using versions higher than "^3.10.1" for "lodash" and "0.21.2" for "yeoman-generator" I get naming collisions on "lodash" , "inquirer" and "cli-width" when running packager. 当使用高于"^3.10.1"版本用于"lodash""0.21.2"用于"yeoman-generator"我在运行打包器时在"lodash""inquirer" "lodash" "inquirer""cli-width"上得到命名冲突。

Reproduction 再生产

Have the dependencies described above and run: react-native start --reset-cache 拥有上面描述的依赖项并运行: react-native start --reset-cache

Result: 结果:

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.

Solution

Using the same versions for "lodash" and "yeoman-generator" as the ones used in react-native@0.36.0 (ie "^3.10.1" for "lodash" and "0.21.2" for "yeoman-generator" ) fixes the issue, but changing them is really not an option for me at the moment, especially because "yeoman-generator" is the dependency of another dependency. 使用相同版本的"lodash""yeoman-generator"中所使用的那些react-native@0.36.0 (即"^3.10.1""lodash""0.21.2""yeoman-generator"修复问题,但是改变它们对我来说真的不是一个选择,特别是因为"yeoman-generator"是另一个依赖的依赖。 Is there any other possible fix? 还有其他可能的解决办法吗?

Thanks! 谢谢!

Update 更新

More details about this issue can be found in the react-native Gihub issue I posted: https://github.com/facebook/react-native/issues/11200 关于这个问题的更多细节可以在我发布的react-native Gihub问题中找到: https//github.com/facebook/react-native/issues/11200

Update 2 更新2

Upgrading react-native to 0.39 solves the problem. react-native升级到0.39解决了这个问题。 The actual fix seems to be the removal of the apparently unused (and maybe outdated) yeoman-generator dependency: https://github.com/facebook/react-native/commit/1fd7a574ba538d05da4be841c84a70766464ec13 实际修复似乎是删除了显然未使用的(也许是过时的) yeoman-generator依赖项: https//github.com/facebook/react-native/commit/1fd7a574ba538d05da4be841c84a70766464ec13

This usually happens when you switch from npm to yarn when installing modules or setting up projects using React Native. 当您在安装模块或使用React Native设置项目时从npm切换到yarn时,通常会发生这种情况。 A simple npm install will usually close this issue without damaging your project's configuration. 简单的npm install通常会关闭此问题而不会损坏项目的配置。

npm install will notify you some of your modules are either deprecated or set up on a different version from the React Native ones and do what it takes to fix it. npm install将通知您某些模块已弃用或与React Native不同的版本设置,并执行修复它所需的操作。 Also, if you wish to really clean up your configuration, notice the npm WARN gentlyRm warnings about packages that are put aside but not removed. 此外,如果您希望真正清理配置,请注意npm WARN gentlyRm警告有关已放弃但未删除的包。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM