【问题标题】:Remove duplicate packages and difference between yarn install --pure-lockfile and yarn install frozen-lockfile删除重复包以及 yarn install --pure-lockfile 和 yarn install freeze-lockfile 之间的区别
【发布时间】:2018-05-22 03:56:17
【问题描述】:

我的 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-lockfileyarn install --frozen-lockfile 会解决这个问题吗?

【问题讨论】:

    标签: package.json yarnpkg


    【解决方案1】:

    所以来自研究 (https://github.com/yarnpkg/yarn/issues/4379)

    Frozen-lockfile 因为它只会在您的锁定文件需要更改并且不一致时才会失败。 纯锁文件你可能有一个接近无用或非常不准确的锁文件,但你仍然不会失败。 Yarn 会简单地使用它愉快计算的内部分辨率。

    最终我解决了重复的包How do I override nested dependencies with `yarn`?。在 package.json 中使用分辨率

    "resolutions": { "react": "16.3.1" }

    【讨论】:

      猜你喜欢
      • 2020-11-21
      • 2017-12-01
      • 2017-05-29
      • 1970-01-01
      • 1970-01-01
      • 2018-05-04
      • 2018-11-15
      • 2013-03-21
      • 2020-10-08
      相关资源
      最近更新 更多