本机包装器故障:重复模块名称。

时间:2022-09-04 10:55:19

This happened seemingly randomly during development. When trying to run npm start or react-native run-ios, I get the following error:

这似乎是在开发过程中随机发生的。当尝试运行npm启动或运行本机运行时,我得到以下错误:

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

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???

奇怪的是,/用户/ chandlervdw /回购/继电器/移动/ node_modules / react-native / local-cli / rnpm /核心/测试/设备/文件/包。json实际上确实列出了反应堆-本机-矢量-图标作为模块的名称??? ?

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.

如果我删除了那个文件,错误就不会再发生了,但是包处理程序被困在93%,并且抱怨没有找到一个完全无关的库。

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.

我去掉了repo,甚至重新安装了所有东西,包括npm、rnpm,甚至升级了node。我和我的队友一样,都在运行相同版本的程序,他们可以毫无问题地运行packager。

4 个解决方案

#1


9  

Posting this as an answer just in case anybody else has this issue in future.

张贴这作为一个答案,以防以后有人有这个问题。

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.

当节点包管理器运行初始构建阶段时,以sudo权限开始运行npm将授予正确的权限。只有当您正在运行的shell/用户具有受限的权限时,才会出现这种情况。强制升级特权给sudo,使包管理器完全控制以完成构建。

#2


4  

I was getting errors like

我犯了一些错误

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

I solved it by deleting npm's cache .npm and rerunning packager with --reset-cache

我通过删除npm的cache .npm并使用reset-cache重新运行packager来解决这个问题

rm -rf ~/.npm

#3


4  

sudo or chown did not fix it for me. I get the same error from the same library, very odd:

sudo或chown没有帮我修好。我从同一个库中得到了相同的错误,非常奇怪:

Failed to build DependencyGraph: @providesModule naming collision:
 Duplicate module name: react-native-vector-icons
  Paths: /Users/collumj/research/k9fresh/ios/build/Build/Products/Debug-iphonesimulator/kisharNine.app/package.json collides with /Users/collumj/research/k9fresh/node_modules/react-native/local-cli/core/__fixtures__/files/package.json

No need for sudo when I encounter this.

当我遇到这个的时候不需要sudo。

Warning: destructive, check in first.

警告:破坏性,请先检查。

rm -rf android ios
git reset --hard
npm start

This fixes it every time. RN 0.39.2

这每次都会修复它。RN 0.39.2

edit: later, I think I fixed this by unlinking the react-native-vector-icons lib; I think the instructions I got made me double up on the linking or were out of date somehow.

编辑:稍后,我想我是通过断开反应堆本机矢量图标库的链接来修复这个问题的;我想我得到的指令使我在链接上加倍或过时了。

#4


3  

After cleaning the nvm cache and reinstalling all node_modules I realized I was having this issue because of react-native-router-flux.

在清理完nvm缓存并重新安装所有node_modules之后,我意识到我遇到了这个问题,因为它是由本地- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

I fixed it with a downgrade from react-native-router-flux@3.38.1 to react-native-router-flux@3.38.0

我将其修正为从反应器-本机-路由-flux@3.38.1降级为反应器-本机-路由-flux@3.38.0

More details here: https://github.com/aksonov/react-native-router-flux/issues/1816

更多细节在这里:https://github.com/aksonov/react-native-router-flux/issues/1816

#1


9  

Posting this as an answer just in case anybody else has this issue in future.

张贴这作为一个答案,以防以后有人有这个问题。

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.

当节点包管理器运行初始构建阶段时,以sudo权限开始运行npm将授予正确的权限。只有当您正在运行的shell/用户具有受限的权限时,才会出现这种情况。强制升级特权给sudo,使包管理器完全控制以完成构建。

#2


4  

I was getting errors like

我犯了一些错误

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

I solved it by deleting npm's cache .npm and rerunning packager with --reset-cache

我通过删除npm的cache .npm并使用reset-cache重新运行packager来解决这个问题

rm -rf ~/.npm

#3


4  

sudo or chown did not fix it for me. I get the same error from the same library, very odd:

sudo或chown没有帮我修好。我从同一个库中得到了相同的错误,非常奇怪:

Failed to build DependencyGraph: @providesModule naming collision:
 Duplicate module name: react-native-vector-icons
  Paths: /Users/collumj/research/k9fresh/ios/build/Build/Products/Debug-iphonesimulator/kisharNine.app/package.json collides with /Users/collumj/research/k9fresh/node_modules/react-native/local-cli/core/__fixtures__/files/package.json

No need for sudo when I encounter this.

当我遇到这个的时候不需要sudo。

Warning: destructive, check in first.

警告:破坏性,请先检查。

rm -rf android ios
git reset --hard
npm start

This fixes it every time. RN 0.39.2

这每次都会修复它。RN 0.39.2

edit: later, I think I fixed this by unlinking the react-native-vector-icons lib; I think the instructions I got made me double up on the linking or were out of date somehow.

编辑:稍后,我想我是通过断开反应堆本机矢量图标库的链接来修复这个问题的;我想我得到的指令使我在链接上加倍或过时了。

#4


3  

After cleaning the nvm cache and reinstalling all node_modules I realized I was having this issue because of react-native-router-flux.

在清理完nvm缓存并重新安装所有node_modules之后,我意识到我遇到了这个问题,因为它是由本地- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

I fixed it with a downgrade from react-native-router-flux@3.38.1 to react-native-router-flux@3.38.0

我将其修正为从反应器-本机-路由-flux@3.38.1降级为反应器-本机-路由-flux@3.38.0

More details here: https://github.com/aksonov/react-native-router-flux/issues/1816

更多细节在这里:https://github.com/aksonov/react-native-router-flux/issues/1816