How to install packages in just one package.json file in Yarn workspaces?

Viewed 12520

I have the classic Lerna set up. root directory, packages folder, 2 subdirectories

I want to just run yarn install inside one package and just to install the dependencies for this package. for some reason when I run it (even from inside this folder) it's then installing node_modules inside the root, packageA and packageB.

is there a solution to just allow me to install node_modules for a chosen directory?

1 Answers

Check out 'focused workspaces' https://classic.yarnpkg.com/blog/2018/05/18/focused-workspaces/

From inside the package you want to work on, run

yarn install --focus

and Yarn will install the local dependencies as well as any dependencies in monorepo-sibling dependencies, but not all dependencies across all packages in the monorepo.

Related