Yarn 之间有什么区别?和新公共(public)管理? 在写这个问题时,我只能在 Internet 上找到一些文章,这些文章显示了像 this 这样的 NPM 命令的 Yarn 等价物是什么。 .
它们是否具有相同的功能(我知道 Yarn 有本地缓存,看起来你只需要下载一次包)但除此之外,从 NPM 迁移到 Yarn 还有什么好处吗?
最佳答案
更新:2018 年 3 月(有点晚了...)
从版本 5 开始,npm
- 生成一个名为
package-lock.json
的“锁文件”,它可以像 yarn(或任何其他)锁定机制一样修复整个依赖关系树, - 制作了一个工具
--save
现在隐含在npm i
中
- 更好的网络和缓存使用
npm 5.7.0 further introduced npm ci
命令通过仅安装在 package-lock.json
中找到的包来在持续集成环境中更快地安装依赖项(如果 package 报告错误-lock.json
和 package.json
不同步。
个人,我仍然使用npm
。
原创
我不愿意直接引用文档,但他们很好解释了原因,简洁到我看不出如何进一步总结这些想法。
主要是:
您始终知道您在每次开发中都会得到相同的结果 机器
它并行化了
npm
没有的操作,并且它可以更有效地利用网络。
人们使用它的生产经验是什么?谁知道呢,对大众来说就是个婴儿。
长话短说 from Yehuda Katz :
From the get-go, the Yarn lockfile guarantees that repeatedly running yarn on the same repository results in the same packages.
Second, Yarn attempts to have good performance, with a cold cache, but especially with a warm cache.
Finally, Yarn makes security a core value.
不错的博文
“NPM vs Yarn Cheat Sheet ” 作者:甘特·拉博德
略长的版本from the project :
Fast: Yarn caches every package it downloads so it never needs to again. It also parallelizes operations to maximize resource utilization so install times are faster than ever.
Reliable: Using a detailed, but concise, lockfile format, and a deterministic algorithm for installs, Yarn is able to guarantee that an install that worked on one system will work exactly the same way on any other system.
Secure: Yarn uses checksums to verify the integrity of every installed package before its code is executed.
来自the README.md :
- Offline Mode: If you've installed a package before, you can install it again without any internet connection.
- Deterministic: The same dependencies will be installed the same exact way across every machine regardless of install order.
- Network Performance: Yarn efficiently queues up requests and avoids request waterfalls in order to maximize network utilization.
- Multiple Registries: Install any package from either npm or Bower and keep your package workflow the same.
- Network Resilience: A single request failing won't cause an install to fail. Requests are retried upon failure.
- Flat Mode: Resolve mismatching versions of dependencies to a single version to avoid creating duplicates.
- More emojis. 🐈
关于javascript - 什么时候使用 Yarn 而不是 NPM?有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40027819/