我使用 yarn add --dev
安装了一个包,运行它的设置过程,在此过程中,该包安装了几个其他包并将它们添加到 package.json
(在 devDependencies
)中,我假设使用 npm。很好,但现在我的 yarn.lock
不同步了。
将 yarn.lock
同步到 package.json
的当前状态的正确、非手动方式是什么?
编辑:yarn check
将丢失的包显示为:
error Lockfile does not contain pattern: <package>@<version>
但它没有添加它们。
最佳答案
运行 yarn install
,或者只是 yarn
。
锁定文件会在依赖项发生任何更改时全部更新,即当您运行 yarn 命令时。
来自 Yarn docs :
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.
(强调我自己的)
关于node.js - 如何将 `yarn.lock` 与 `package.json` 同步?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41126217/