React-Native Packager 失败:重复的模块名称 [英] React-Native Packager Failure: Duplicate module name
问题描述
这在开发过程中似乎是随机发生的.尝试运行 npm start
或 react-native run-ios
时,出现以下错误:
This happened seemingly randomly during development. When trying to run npm start
or react-native run-ios
, I get the following error:
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
作为模块的名称???
Strangely, /Users/chandlervdw/Repos/Relay/mobile/node_modules/react-native/local-cli/rnpm/core/test/fixtures/files/package.json
actually does list react-native-vector-icons
as the name for the module???
如果我删除该文件,错误不再发生,但打包程序会卡在 93% 并抱怨找不到完全不相关的库.
If I delete that file, the error no longer happens but the packager gets stuck at 93% and complains about a completely irrelevent library not being found.
我炸毁了我的 repo,甚至重新安装了所有东西,包括 npm
、rnpm
,甚至升级了 node
.我正在运行与我的队友相同版本的所有内容,他们能够毫无问题地运行打包程序.
I blew away my repo and even reinstalled everything, including npm
, rnpm
, and even upgrading node
. I'm running the same versions of everything as my teammates, who are able to run the packager without issues.
推荐答案
将此作为答案发布,以防其他人将来遇到此问题.
使用 sudo
权限运行 npm start
会在节点包管理器运行初始构建阶段时授予正确的权限.这似乎只有在您运行的 shell/用户具有受限权限时才会发生.将权限强制提升到 sudo 可以让包管理器完全控制以完成构建.
Running npm start
with sudo
permissions grants the correct privileges when nodes package manager is running the initial build phase. This only seems to happen if the shell/user that you are running from has restricted privileges. Force escalating privileges to sudo gives the package manager full control to complete the build.
这篇关于React-Native Packager 失败:重复的模块名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!