尝试理解为什么我遇到了意外的未满足对等依赖错误。

huangapple go评论55阅读模式
英文:

Try to understand why i'm having an unexpected UNMET PEER DEPENDENCY error

问题

当我运行 npm ls react-dom 时,它在我的项目中返回以下图形:

package1@28.4.0 /Volumes/Workspace/package1_WT/dev
├─┬ @storybook/components@5.1.11
│ └── UNMET PEER DEPENDENCY react-dom@16.14.0 
├─┬ @storybook/react@5.1.11
│ └─┬ @storybook/core@5.1.11
│   └─┬ @storybook/ui@5.1.11
│     └── UNMET PEER DEPENDENCY react-dom@16.14.0 
├─┬ randomPackage@12.21.1
│ └── UNMET PEER DEPENDENCY react-dom@17.0.2  deduped
└── UNMET PEER DEPENDENCY react-dom@17.0.2

package.json 将 "react-dom" 声明为依赖项(而不是 peerDependency):"react-dom": "~17.0.0"。实际上,在检查 node_modules 时,已安装了 react-dom 的 17.0.2 版本,它实际上在 "~17.0.0" 的范围内。

为什么根 package.json 返回 "UNMET PEER DEPENDENCY react-dom@17.0.2" 的错误?而对于 storybook 包来说这实际上是有道理的。

英文:

When I npm ls react-dom it returns on my project the following graph

package1@28.4.0 /Volumes/Workspace/package1_WT/dev
├─┬ @storybook/components@5.1.11
│ └── UNMET PEER DEPENDENCY react-dom@16.14.0 
├─┬ @storybook/react@5.1.11
│ └─┬ @storybook/core@5.1.11
│   └─┬ @storybook/ui@5.1.11
│     └── UNMET PEER DEPENDENCY react-dom@16.14.0 
├─┬ randomPackage@12.21.1
│ └── UNMET PEER DEPENDENCY react-dom@17.0.2  deduped
└── UNMET PEER DEPENDENCY react-dom@17.0.2

The package.json is having declared as a dependency (not as a peerDependency) "react-dom": "~17.0.0". Actually when checking the node_modules, version 17.0.2 of react-dom is installed which actually falls into the range of "~17.0.0".

Why is it returning an UNMET PEER DEPENDENCY react-dom@17.0.2 error for the root package.json ? while it actually make sense for the storybook packages

答案1

得分: 1

Storybook的版本(具体来说是@storybook/components@storybook/ui),你已经安装的版本表明它们依赖于react-dom@16.14.0

react-dom@17.0.2是一个不同的主要版本。

你的主包直接依赖的内容与通过Storybook间接依赖的内容之间存在冲突。

你可能可以通过升级Storybook来解决这个问题。

英文:

The version of Storybook (specifically @storybook/components and @storybook/ui) that you have installed say they depend on react-dom@16.14.0.

react-dom@17.0.2 is a different major version.

You've got a conflict between what your main package depends on directly and what it depends on indirectly via Storybook.

You can probably resolve this by upgrading Storybook

huangapple
  • 本文由 发表于 2023年3月3日 23:53:05
  • 转载请务必保留本文链接:https://go.coder-hub.com/75629246.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定