Managing a monorepo with Nx to enhance Lerna
Earlier in this chapter when we discussed Lerna, one thing we did not mention is that there is a special key in lerna.json
, which is called useNx
and configured to be true
. This is a new addition to Lerna 5, which is now maintained by the people behind Nx – another popular solution for managing monorepos. So, what does this actually bring and how can it enhance Lerna – or any other monorepo management tool?
With Lerna or without?
Nx does not depend on Lerna and the use of Nx within Lerna is also optional. Therefore, the two technologies can be seen as non-exclusive – rather, they complete each other. In the end, it is your choice to decide which technologies you’d like to use. The example in this section, for instance, does not use Lerna.
We start with a new repository again. This time, we’ll use the nx-workspace
npm initializer provided by Nx:
$ npm init nx-workspace -- --preset=react
Workspace...