如何将`yarn.lock`与`package.json`同步? [英] How to sync `yarn.lock` with `package.json`?

查看:380
本文介绍了如何将`yarn.lock`与`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屋!

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