node.js - 如何将 `yarn.lock` 与 `package.json` 同步?

标签 node.js package.json yarnpkg

我使用 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/

相关文章:

node.js - package.json 中属性 "private"的用途是什么?

node.js - 引擎 "node"与此模块不兼容。预期版本 "12.x"。得到 "14.8.0"

node.js - (NODEJS) 快速全局安装不工作

javascript - postgres 不支持 TypeORM 数组?

reactjs - Node-sass 是 React 项目的开发依赖还是生产依赖?

node.js - 使用 npm-check-updates 更新时未找到 Package.json 错误

node.js - Puppeteer 无法在谷歌云功能中工作

node.js - 使用socket.io 广播的效率与向每个客户端发送消息的效率相同

reactjs - React,Typescript - 找不到模块...或其相应的类型声明

git - 作为 npm 依赖项的私有(private) Typescript 库