我应该提交 yarn.lock 文件吗?它有什么用? [英] Should I commit the yarn.lock file and what is it for?

查看:89
本文介绍了我应该提交 yarn.lock 文件吗?它有什么用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Yarn 在您执行 yarn install 后会创建一个 yarn.lock 文件.

Yarn creates a yarn.lock file after you perform a yarn install.

这应该提交到存储库还是忽略?有什么用?

Should this be committed to the repository or ignored? What is it for?

推荐答案

是的,您应该检查它,请参阅 从 npm 迁移

Yes, you should check it in, see Migrating from npm

为什么要这样做?
npm 客户端不确定地将依赖项安装到 node_modules 目录中.这意味着根据安装依赖项的顺序,node_modules 目录的结构可能因人而异.这些差异可能会导致在我的机器上运行需要很长时间才能找到的错误.

Why is it for?
The npm client installs dependencies into the node_modules directory non-deterministically. This means that based on the order dependencies are installed, the structure of a node_modules directory could be different from one person to another. These differences can cause works on my machine bugs that take a long time to hunt down.

Yarn 通过使用锁定文件和确定性和可靠的安装算法解决了有关版本控制和非确定性的这些问题.这些锁定文件将已安装的依赖项锁定到特定版本,并确保每次安装都会在所有机器上的 node_modules 中产生完全相同的文件结构.

Yarn resolves these issues around versioning and non-determinism by using lock files and an install algorithm that is deterministic and reliable. These lock files lock the installed dependencies to a specific version and ensure that every install results in the exact same file structure in node_modules across all machines.

这篇关于我应该提交 yarn.lock 文件吗?它有什么用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆