Lerna
Last updated
Was this helpful?
Last updated
Was this helpful?
When I first had a look at , I couldn't understand how it works and what was its value. Essentially, what would have been a repository is now a folder in packages
. All the dependencies will be installed with lerna bootstrap
.
What does this mean? When you clone the monorepo, you will get all the code required to run the app. When you run yarn install
you'll install all the dependencies.
Create lerna.json
Install Lerna at the root of the project.
Go to the packages/api
and install express
The express
dependency should have been added to packages/api/package.json
Let's do the same for packages/web
and add react
We should now have node_modules
folders in api
and web
.
Let's try to delete both node_modules
folders and bootstrap from the project's root directory. It should install all dependencies.
We can add anything in scripts
of our package.json
and run it with yarn name-of-script
.
Let's try this first with our package.json
from the root directory, :
We can add our bootstrap step here:
We can now install all the dependencies from the root directory:
There are pre-defined keywords for npm-scripts
. You can find all of them but we are interested in postinstall
.
branch available on GitHub.