【问题标题】:Duplicate module name: react-native-vector-icons重复的模块名称:react-native-vector-icons
【发布时间】:2017-04-21 10:51:34
【问题描述】:

当我在我的 react-native 项目中安装 NativeBase 和 React-Native-Router-Flux 时,出现以下错误:

Failed to build DependencyGraph: @providesModule naming collision:
  Duplicate module name: react-native-vector-icons
  Paths: /Users/vittori/Desktop/repos/GitHubExamples/native-starter-kit/node_modules/react-native/local-cli/core/__fixtures__/files/package.json collides with /Users/vittori/Desktop/repos/GitHubExamples/native-starter-kit/node_modules/react-native-router-flux/node_modules/react-native/local-cli/core/__fixtures__/files/package.json

This error is caused by a @providesModule declaration with the same name across two different files.
Error: @providesModule naming collision:
  Duplicate module name: react-native-vector-icons
  Paths: /Users/vittori/Desktop/repos/GitHubExamples/native-starter-kit/node_modules/react-native/local-cli/core/__fixtures__/files/package.json collides with /Users/vittori/Desktop/repos/GitHubExamples/native-starter-kit/node_modules/react-native-router-flux/node_modules/react-native/local-cli/core/__fixtures__/files/package.json

This error is caused by a @providesModule declaration with the same name across two different files.
    at HasteMap._updateHasteMap (/Users/vittori/Desktop/repos/GitHubExamples/native-starter-kit/node_modules/react-native/packager/src/node-haste/DependencyGraph/HasteMap.js:159:13)
    at p.getName.then.name (/Users/vittori/Desktop/repos/GitHubExamples/native-starter-kit/node_modules/react-native/packager/src/node-haste/DependencyGraph/HasteMap.js:134:31)

【问题讨论】:

  • react-native start 开始时,我遇到了同样的问题。运行 npm i 确实有一些关于 react-dom、react-native、react-native-maps、react-native 和 react-static-container 的警告,它们需要一个对等的 react。我尝试了很多事情,例如清理 npm 缓存、删除 node_modules、使用 react-native 升级。让我知道你的进展情况:)

标签: react-native react-native-router-flux native-base


【解决方案1】:

解决方案已发布here

yarn add react-native-router-flux@3.38.0

【讨论】:

    【解决方案2】:

    您应该能够更新 react-native-router-flux 使用: npm i react-native-router-flux --save

    可能是尝试启动 react-native 打包器再次失败,运行可能有用:

    1. Clear watchman watches: `watchman watch-del-all`. 2. Delete the `node_modules` folder: `rm -rf node_modules && npm install`. 3. Reset packager cache: `rm -fr $TMPDIR/react-*` or `npm start --reset-cache`.

    您可能会在尝试再次运行打包程序时看到错误,例如:

    Failed to build DependencyGraph: @providesModule naming collision: Duplicate module name

    您可能需要再次为 react-native-router-flux 运行 npm install。

    【讨论】:

    • 用新的代码库尝试了这些说明 3 次。还尝试清除所有内容并使用yarn. 发生相同的错误
    【解决方案3】:

    如果您使用纱线,请运行此命令。 yarn add react-native-router-flux@3.38.0

    如果您使用 npm,请运行此命令。 npm install react-native-router-flux@3.38.0 --save

    另外你仍然遇到这个问题,请将 react-native 版本降级到 0.41.2。

    然后,它会工作。

    【讨论】:

      【解决方案4】:

      NativeBase 2.1.4 解决了这个问题

      【讨论】: