Home > Article > Web Front-end > Lerna – The key of Monorepo Management
Welcome Back to Monorepo Castle!
The castle is now built, and every room (project) is in place. But without the right management, things could get messy. Who will help the castle run smoothly? That’s when Lerna enters—a powerful wizard with magical commands that keep everything in order.
Lerna is your guide in the land of monorepo, making sure all the rooms (projects) are in sync, all the packages are linked, and nothing falls apart.
Lerna isn't just any wizard—it’s a super wizard designed to make your life easier while managing multiple projects in one repo. Let’s take a peek at some of Lerna’s spells (commands):
1. lerna init – The “Let’s Build a Castle” Spell
This is where it all starts. You summon Lerna with this command, and it sets up the structure for your monorepo. It’s like laying the foundation for your castle—each room has its place.
lerna init
Your monorepo is ready! ?
2. lerna bootstrap – The “Let’s Connect Everything” Spell
Now that the rooms are built, they need to communicate. Lerna connects the different rooms by linking dependencies. It’s like setting up magical tunnels between rooms.
lerna bootstrap
3. lerna add – The “New Magic for Specific Rooms” Spell
Need to add a new library (package) to one room only? No problem! Lerna casts this spell to install it only where you need it, saving time and avoiding mess.
lerna add axios --scope=frontend
4. lerna run – The “Let’s Get Things Moving” Spell
Want to run scripts in all rooms at the same time? Lerna can do that with ease! It’s like commanding the entire castle staff to start work at once.
lerna run start
5. lerna clean – The “Declutter the Castle” Spell
Sometimes, the castle (repo) gets cluttered with unnecessary stuff (like node_modules). Lerna can clean it all out with one wave of its wand.
lerna clean
With Lerna by your side, managing a monorepo becomes an absolute easy. From syncing dependencies to running scripts across projects, Lerna keeps the castle organized, efficient, and fast.
Stay tuned for more wizardry as we explore other tools in this magical land of web development. ✨
till then, Happy Coding ! ??
The above is the detailed content of Lerna – The key of Monorepo Management. For more information, please follow other related articles on the PHP Chinese website!