Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to avoid install of packages in monorepo using Yarn

I built a monorepo using Lerna and Yarn workspaces.

Everything works fine but everytime I install a new dependency on a package (let's call him A) using:

yarn add <package_name>

Yarn adds it and then triggers the install script of all the packages in the monorepo, even the ones that A doesn't rely on.

It there anyway to avoid this? It takes a few moment to install them for no reason at all.

like image 280
Erazihel Avatar asked Mar 26 '20 19:03

Erazihel


People also ask

Does lerna use yarn?

We can also define which package manager Lerna uses, such as npm or yarn. The above command also initializes a package folder where the projects can be located. In the lerna. json file, add the npmClient option to specify yarn as the package manager.

How do I add a package to Monorepo?

Step 3 — Installing Packages in the Monorepo Lerna can help you manage packages and dependencies across projects within the monorepo. To add a package to your project, use the lerna exec command to execute a shell command: lerna exec npm i lite-server --parallel.

Does yarn install from package json?

yarn install is used to install all dependencies for a project. The dependencies are retrieved from your project's package. json file, and stored in the yarn.


1 Answers

Try adding to the specific workspace with:-

yarn workspace <workspace_name> add <package_name>

For some docs check here

like image 77
Ezrqn Kemboi Avatar answered Sep 22 '22 06:09

Ezrqn Kemboi