英文:
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论