Kenneth Truong
Kenneth Truong

Reputation: 4176

How do I keep yarn workspaces dependencies in sync

Let's say I have multiple packages in my yarn workspaces.

@mycompany/utils
@mycompany/app
@mycompany/serv

Let's say each of these packages has a dependency on lodash. I want to make sure that they all have the same lodash version.

Is there a way to do that in each of the package.json?

Upvotes: 16

Views: 3946

Answers (1)

Stav Alfi
Stav Alfi

Reputation: 13953

Use syncpack to force all sub-packages in a monorepo uses the same version of each dependency.

Install in the root package.json:

yarn add --dev -W syncpack

Run (Recommnded: Run on every commit using husky):

syncpack list-mismatches

More info: https://github.com/JamieMason/syncpack

Upvotes: 10

Related Questions