如何避免使用Yarn在monorepo中安装软件包

问题描述 投票:2回答:3

我使用LernaYarn工作区构建了一个monorepo。

一切正常,但是每次我使用以下方法在软件包上安装新的依赖项时(我们称他为A):

yarn add <package_name>

Yarn添加它,然后触发monorepo中所有包的install脚本,甚至是A不依赖的包。

无论如何都可以避免这种情况?完全无需花费一些时间即可安装它们。

javascript yarnpkg npm-scripts lerna monorepo
3个回答
0
投票

尝试使用以下方法添加到特定的工作区:-

yarn workspace <workspace_name> add <package_name>

对于某些文档check here


0
投票

您可以在nodeLinker: node-modules中使用.yarnrc.yml尝试使用纱2。 Yarn 2保证只在依赖项已更改的程序包上触发重建,这是Yarn 1不能保证的。但是,如果在添加新程序包后以不同的方式提升它们似乎无关紧要的程序包,则仍然存在非常罕见的情况,但是这种情况很少发生。


0
投票

使用范围将包添加到特定模块。

lerna add some_package_1 --scope=some_module_x

更多:https://github.com/lerna/lerna/tree/master/commands/add#readme

© www.soinside.com 2019 - 2024. All rights reserved.