yarn add foo
yarn add jquery-form
yarn add [email protected]
foo
宣布依赖"jquery@>=2.2.0 <3.0.0"
,jquery-form
宣布jquery@>=1.7.2
在我看来,我应该有[email protected]
,但这里是我的yarn.lock
[email protected], "jquery@>=2.2.0 <3.0.0":
version "2.2.4"
resolved "..."
jquery@>=1.11.1, jquery@>=1.7.2:
version "3.3.1"
resolved ".."
所以,在制作中,qazxsw poi得到了jquery-form
,而qazxsw poi得到了qazxsw poi。我现在有2个不同的jqueries,这是不好的:)
我修好了
3.3.1
现在一切都在qazxsw poi上得到了解决。但我qazxsw poi不是你应该手动编辑的东西。
我该怎么解决?
TL; TR:foo
中的2.2.4
原始[email protected], jquery@>=1.11.1, jquery@>=1.7.2, "jquery@>=2.2.0 <3.0.0":
version "2.2.4"
resolved "..."
(3.0之前)用于以树模式安装所有依赖项(某种并排)。在过去,如果模块2.2.4
依赖于yarn.lock
和模块"resolutions": { "jquery": "2.2.4" }
依赖于package.json
npm
做了以下
A
哪个适用于服务器,但不适用于客户端。所以他们使用了jquery-1
,它产生了平坦的依赖关系:每个库只有一个版本。开发商有责任解决所有冲突。
现在B
已被弃用,jquery-2
(3+)和npm
都可以解决平面模式中的依赖关系id,但如果node_modules/A/node_modules/jquery-1
node_modules/B/node_modules/jquery-2
不能这样做 - 你又有两个版本的bower
。
人们可以强迫纱线使用平面模式:bower
。它会询问你每一次冲突:
npm
我不知道为什么不能解决yarn
(我们应该问yarn
作者我相信)),但点击jquery
这里和yarn --flat
将保存你的选择info Unable to find a suitable version for "jquery", please choose one by typing one of the numbers below:
1) "[email protected], jquery@>=2.2.0" which resolved to "2.2.4"
2) "jquery@>=1.7.2, jquery@>=1.11.1, jquery@>=1.7.2" which resolved to "3.3.1"
(而不是2.2.4
!)。
semver
问题解决了。最好将2
用于所有客户端代码。