Today I spent some time learning about and evaluating the tool Lerna. Here's what I picked up.

What is Lerna?

From the docs: "A tool for managing JavaScript projects with multiple packages." When I first read this it didn't make complete sense so I had to dig in further.

Lerna is an NPM installable tool that you install on top of your existing project. When you init it, it adds some extra directories/files and structure to your app which enables some handy tools which you can run against your projects to add some quality-of-life features.

What kind of QoL features?

  • It can do some fancier npm-link functionality for allowing you to reference other packages in your mono-repo via symlinks. This is helpful since in a monorepo you cannot npm install from github links npm i http://github.
  • It can help you run scripts across all of your packages. For instance learna run test will kick off the npm run test in all of your packages. This can be used for other scripts like for building your code.
  • It can help you with creating new versions of your packages for releasing code with some intelligent features like only updating versions when necessary.
  • It will maintain a Changelog keeping track of everything that is in a release.
  • It will give you a diff tool which enables you to see the changes in all commits across all packages since the last release.

Who should use Lerna?

If you run a Monorepo it might be worth using Lerna. If you don't use a monorepo I doubt it's worth adding. In my current role I don't believe it's a good fit for what we do, as we have the opposite of a Monorepo. Our frontend stack is a MicroServices architecture.

If I've missed anything please drop me a message in the comments below. Thanks!