Published on

Trying Out Lerna


Today I set up a simple project to understand a bit better how to use Lerna. The setup was pretty simple:

# create a new repo
mkdir my-new-mono-repo
cd my-new-mono-repo
git init
lerna init

Now to create a new repo (let us call it my-awesome-repo) that sits in this monorepo simply run:

lerna create my-awesome-repo

Lerna adds each new sub-repo into the packages folder.

Where it gets interesting is if you need to run some action across all the repos:

  • Add a common dependency: lerna add my-npm-dependency
  • Run a common NPM script: lerna run build

One issue I ran into off the bat with Lerna is that create react app (CRA) generated apps do not play nice with Lerna as described here. As a result I will resort back to using my own handrolled monorepo for small monorepos until a fix on the CRA side has been implemented.