如何将`yarn.lock`与`package.json`同步? [英] How to sync `yarn.lock` with `package.json`?
问题描述
我用yarn add --dev
安装了一个软件包,运行其设置过程,在安装过程中,该软件包还安装了其他几个软件包并将它们添加到package.json
(在devDependencies
中),我假设使用 npm >.很好,但是现在我的yarn.lock
不同步.
I installed a package with yarn add --dev
, run its setup process and during it, the package installed several other packages and added those to package.json
(in devDependencies
), I assume with npm. Great, but now my yarn.lock
is out of sync.
将yarn.lock
同步到package.json
的当前状态的正确,非手动方法是什么?
What is the correct, non-manual way of syncing yarn.lock
to the current state of package.json
?
yarn check
将缺少的软件包显示为:
yarn check
shows the missing packages as:
error Lockfile does not contain pattern: <package>@<version>
但是它没有添加它们.
推荐答案
运行yarn install
或仅运行yarn
.
在对依赖项进行任何更改时,即在您运行yarn命令时,锁文件都会完整更新.
The lock file is updated in its entirety on any change to dependencies, i.e. when you run a yarn command.
从纱线文档中:
您的yarn.lock文件是自动生成的,应完全由Yarn处理. 当您使用Yarn CLI添加/升级/删除依赖项时,它将自动更新您的yarn.lock文件.请勿直接编辑此文件,因为它很容易破坏某些内容.
Your yarn.lock file is auto-generated and should be handled entirely by Yarn. As you add/upgrade/remove dependencies with the Yarn CLI, it will automatically update your yarn.lock file. Do not edit this file directly as it is easy to break something.
(强调自己的意思)
这篇关于如何将`yarn.lock`与`package.json`同步?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!