node.js - React-Native 打包程序失败 : Duplicate module name

标签 node.js npm react-native packager

这在开发过程中似乎是随机发生的。尝试运行 npm startreact-native run-ios 时,出现以下错误:

Failed to build DependencyGraph: @providesModule naming collision:
  Duplicate module name: react-native-vector-icons
  Paths: /Users/chandlervdw/Repos/Relay/mobile/node_modules/react-native/local-cli/rnpm/core/test/fixtures/files/package.json collides with /Users/chandlervdw/Repos/Relay/mobile/node_modules/react-native/Libraries/Animated/release/package.json

This error is caused by a @providesModule declaration with the same name accross two different files.
Error: @providesModule naming collision:
  Duplicate module name: react-native-vector-icons
  Paths: /Users/chandlervdw/Repos/Relay/mobile/node_modules/react-native/local-cli/rnpm/core/test/fixtures/files/package.json collides with /Users/chandlervdw/Repos/Relay/mobile/node_modules/react-native/Libraries/Animated/release/package.json

This error is caused by a @providesModule declaration with the same name accross two different files.
    at HasteMap._updateHasteMap (/Users/chandlervdw/Repos/Relay/mobile/node_modules/node-haste/lib/DependencyGraph/HasteMap.js:162:15)
    at /Users/chandlervdw/Repos/Relay/mobile/node_modules/node-haste/lib/DependencyGraph/HasteMap.js:140:25

奇怪的是,/Users/chandlervdw/Repos/Relay/mobile/node_modules/react-native/local-cli/rnpm/core/test/fixtures/files/package.json实际上确实列出了react-native-vector-icons 作为模块的名称???

如果我删除该文件,错误将不再发生,但打包程序卡在 93% 并提示找不到完全不相关的库。

我删除了我的 repo,甚至重新安装了所有东西,包括 npmrnpm,甚至升级了 node。我正在运行与我的队友相同的版本,他们能够毫无问题地运行打包程序。

最佳答案

将此作为答案发布,以防其他人将来遇到此问题。

sudo 权限运行 npm start 可在 Node 包管理器运行初始构建阶段时授予正确的权限。这似乎仅在您运行的 shell/用户具有受限权限时才会发生。强制将权限升级到 sudo 可以让包管理器完全控制以完成构建。

关于node.js - React-Native 打包程序失败 : Duplicate module name,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38885760/

相关文章:

node.js - 找不到 nodemon 命令

javascript - 在 node-mysql 中使用 SSH 隧道连接到 MySQL

android - React-native 获取通话记录(Android/iOS)

android - 在 react-native 中管理堆栈的最佳导航方法是什么?

javascript - imap.search 时 Node.js imap 库中出现错误协议(protocol)错误

node.js - 带有参数的 Axios Node.Js GET 请求未定义

node.js - 使用 Express JS 检查 API 请求授权的更好方法

node.js - 从 NPM 包中导出多个模块

react-native - 如何解决滚动中包含多个平面列表的虚拟列表警告

javascript - Mongoose :为什么我没有收到错误响应