在1.5.11中,我的依赖项中有angular:
{
"dependencies": {
"angular": "1.5.11",
"angular-foundation": "0.7.0"
}
}angular-foundation恰好依赖于angular@>=1.3.0。
为什么Yarn将angular@1.6.9安装为angular-foundation的嵌套依赖,而不是使用项目的版本?这会导致angular在应用程序中出现两次,并且无法正常工作:
node_modules angular (1.5.11) angular-foundation (0.7.0) node_modules angular (1.6.9)
npm@5.6.0不会出现这种情况-- npm使用1.5.11作为应用程序和包。
发布于 2018-03-06 16:42:24
为此,您需要使用Yarn分辨率
https://yarnpkg.com/lang/en/docs/selective-version-resolutions/
所以你的package.json会变成这样
{
"name": "depdencies",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"angular": "1.5.11",
"angular-foundation": "0.7.0"
},
"resolutions": {
"**/angular": "1.5.11"
}
}这将告诉yarn任何子角度依赖项都将被设置为1.5.11。在更新此程序后,请在下面运行
$ rm yarn.lock
$ yarn发布于 2020-11-05 11:33:21
https://classic.yarnpkg.com/en/docs/cli/add/#toc-yarn-add-alias
yarn add <alias-package>@npm:<package>
yarn add react17@npm:react@17
https://stackoverflow.com/questions/49072905
复制相似问题