删除重复包和 yarn install --pure-lockfile 和 yarn install frozen-lockfile 之间的区别
Remove duplicate packages and difference between yarn install --pure-lockfile and yarn install frozen-lockfile
我的package.json(react-native@0.55.4需要react@16.3.1)
"dependencies": {
"expo": "^27.0.1",
"react": "16.3.1",
"react-native": "~0.55.2",
"react-navigation": "^2.0.1"
}
我的 yarn.lock 文件中有重复的包。
react@16.3.1:
version "16.3.1"
resolved "https://registry.yarnpkg.com/react/-/react-16.3.1.tgz#4a2da433d471251c69b6033ada30e2ed1202cfd8"
dependencies:
fbjs "^0.8.16"
loose-envify "^1.1.0"
object-assign "^4.1.1"
prop-types "^15.6.0"
react@^16.0.0:
version "16.3.2"
resolved "https://registry.yarnpkg.com/react/-/react-16.3.2.tgz#fdc8420398533a1e58872f59091b272ce2f91ea9"
dependencies:
fbjs "^0.8.16"
loose-envify "^1.1.0"
object-assign "^4.1.1"
prop-types "^15.6.0"
运行 $ yarn remove react
,结果是
react@^16.0.0:
version "16.3.2"
resolved "https://registry.yarnpkg.com/react/-/react-16.3.2.tgz#fdc8420398533a1e58872f59091b272ce2f91ea9"
dependencies:
fbjs "^0.8.16"
loose-envify "^1.1.0"
object-assign "^4.1.1"
prop-types "^15.6.0"
如果我再次尝试 运行,我会得到 error This module isn't specified in a manifest.
如何强制 yarn 删除所有 react 版本,以便我可以手动安装我需要的版本?
yarn install 只需添加这两个包。
yarn install --pure-lockfile
或 yarn install --frozen-lockfile
会解决这个问题吗?
所以根据研究 (https://github.com/yarnpkg/yarn/issues/4379)
Frozen-lockfile 因为它只有在您的锁文件需要更改且不一致时才会失败。
纯锁文件你可能有一个接近无用或非常不准确的锁文件,但你仍然不会失败。 Yarn 会简单地使用它愉快地计算的内部分辨率。
最终我解决了重复的包。使用 package.json
中的分辨率
"resolutions": {
"react": "16.3.1"
}
我的package.json(react-native@0.55.4需要react@16.3.1)
"dependencies": {
"expo": "^27.0.1",
"react": "16.3.1",
"react-native": "~0.55.2",
"react-navigation": "^2.0.1"
}
我的 yarn.lock 文件中有重复的包。
react@16.3.1:
version "16.3.1"
resolved "https://registry.yarnpkg.com/react/-/react-16.3.1.tgz#4a2da433d471251c69b6033ada30e2ed1202cfd8"
dependencies:
fbjs "^0.8.16"
loose-envify "^1.1.0"
object-assign "^4.1.1"
prop-types "^15.6.0"
react@^16.0.0:
version "16.3.2"
resolved "https://registry.yarnpkg.com/react/-/react-16.3.2.tgz#fdc8420398533a1e58872f59091b272ce2f91ea9"
dependencies:
fbjs "^0.8.16"
loose-envify "^1.1.0"
object-assign "^4.1.1"
prop-types "^15.6.0"
运行 $ yarn remove react
,结果是
react@^16.0.0:
version "16.3.2"
resolved "https://registry.yarnpkg.com/react/-/react-16.3.2.tgz#fdc8420398533a1e58872f59091b272ce2f91ea9"
dependencies:
fbjs "^0.8.16"
loose-envify "^1.1.0"
object-assign "^4.1.1"
prop-types "^15.6.0"
如果我再次尝试 运行,我会得到 error This module isn't specified in a manifest.
如何强制 yarn 删除所有 react 版本,以便我可以手动安装我需要的版本?
yarn install 只需添加这两个包。
yarn install --pure-lockfile
或 yarn install --frozen-lockfile
会解决这个问题吗?
所以根据研究 (https://github.com/yarnpkg/yarn/issues/4379)
Frozen-lockfile 因为它只有在您的锁文件需要更改且不一致时才会失败。 纯锁文件你可能有一个接近无用或非常不准确的锁文件,但你仍然不会失败。 Yarn 会简单地使用它愉快地计算的内部分辨率。
最终我解决了重复的包
"resolutions": {
"react": "16.3.1"
}