Blog
Juri Strumpflohner
October 12, 2022

Lerna reborn — What's new in v6?

Lerna reborn — What's new in v6?

Lerna v6 is out!! Here's everything you need to know about the new Lerna experience!

Table of Contents

· Lerna continues to evolve
· Fast Lerna with caching by default
· Remote caching with Lerna
· Defining a task pipeline
· Lerna add-caching command
· PNPM support for Lerna
· Dynamic terminal output
· VSCode extension for Lerna workspaces
· Lerna Repair
· Lerna and Prettier
· Migrating to Lerna v6
· Lerna is using Nx now. Can I keep using my Lerna commands?
· Are you maintaining an OSS repository using Lerna?

Lerna continues to evolve

If you already know this, feel free to skip ahead. But surprisingly many still haven't heard that Lerna is back, far from obsolete or deprecated and is getting brand new features. We from Nrwl are the creators of Nx and given our long history in the monorepo space, we offered to take over stewardship of Lerna when it was declared "dead" in April 2022.

Since we took over, in May 2022, it has been an absolute rollercoaster. We launched a brand new website, updated the content of the docs, and made Lerna 10x faster. And now, Lerna v6 is out!

Fast Lerna with caching by default

Up until Lerna v4, either the p-map or p-queue npm packages have been used to delegate the task scheduling. With v5.1 we introduced nx as an additional mechanism to schedule tasks. The advantage? Nx has caching built-in, which also gives Lerna caching support, making it lightning fast. A recent benchmark test resulted in Lerna being 2.5x faster than Lage and around 4x faster than Turbo (as of Oct 2022; test it out by yourself).

So far you had to enable "Nx support" by setting the useNx flag in lerna.json:

1// lerna.json 2{ 3 ... 4 "useNx": true 5} 6

We've been testing this opt-in for the last couple of months and got tons of amazing feedback from companies and open source projects. As a result, with v6 all Lerna workspaces have the useNx set to **true** by default even if you don't have it in your Lerna config file. If you don't want to use it, you can disable it by setting the flag to false.

To experience fast caching, ensure you have a nx.json file at the root of your Lerna workspace where you define the cacheable operations. Check out the docs for more details. Here's an example configuration file:

1{ 2 "tasksRunnerOptions": { 3 "default": { 4 "runner": "nx/tasks-runners/default", 5 "options": { 6 "cacheableOperations": ["build", "test"] 7 } 8 } 9 } 10} 11

Note that you can also run..

1 2