删除重复的包和纱线安装--pure-lockfile和yarn install frozen-lockfile之间的区别

时间:2018-05-22 03:56:17

标签: package.json yarnpkg

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

1 个答案:

答案 0 :(得分:0)

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

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

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

中的分辨率

{{1}}