lerna advantage with yarn workspaces, why use lerna at all

Viewed 697

I'm trying to setup a mono repo and came across lerna+yarn. My problem is, what is the actual advantage I get in using lerna. I can use yarn workspaces only and have the same functionality. I came across the following Are there any advantages to using Lerna with Yarn workspaces? but here there is no specific answer as to the specific advantage of using lerna.

2 Answers

as stated in the yarn workspaces documentation,

workspaces are the primitives that tools like lerna can use

You might have a project that only needs workspaces as "primitives", and not lerna. Both are tools, but lerna as a higher-level-tool than yarn workspaces helps you organize your monorepo when you are working on open source or in a team:

The install (bootstrap) / build / start-scripts are at the project root:

  • meaning one install and package resolution instead of one for each package
  • node_modules at the root is 'fat', in sub-projects it's tiny: One place to look for when you resolve package conflicts
  • parallel execution of scripts in sub-projects: E.g. starting up both server and frontend development in watch-mode can just be one command
  • publishing and versioning is much easier

There is certainly a lot of overlap between the two. The big difference is that Lerna handles package management, versioning and deployment.

Related