Search code examples
javascriptyarnpkgnpm-scriptslernamonorepo

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.


Solution

  • Try adding to the specific workspace with:-

    yarn workspace <workspace_name> add <package_name>
    

    For some docs check here