How to Use Lerna with Turborepo and Nx for Monorepo Success

Written By:
Founder & CTO
June 25, 2025
Understanding the Modern Monorepo Landscape

In today’s fast-paced development environment, engineering teams increasingly rely on monorepo architectures to manage complex software ecosystems. A monorepo, short for monolithic repository, houses all your apps, packages, and libraries in a single unified codebase. The key benefits of monorepos are rooted in visibility, maintainability, and productivity.

But managing a large monorepo isn’t straightforward. It involves orchestrating multiple build tools, maintaining dependencies, sharing utilities, and optimizing CI/CD pipelines to reduce build times and duplication. That’s where tools like Lerna, Nx, and Turborepo come into play.

Each of these tools targets a unique aspect of monorepo success:

  • Lerna manages JavaScript/TypeScript projects with multiple packages, offering utilities like versioning, bootstrapping, and local linking.

  • Nx adds intelligent dependency graph analysis, remote caching, and affected project detection.

  • Turborepo, developed by Vercel, focuses on build optimization and incremental task execution for JavaScript monorepos.

Let’s break down how these tools complement each other, and how developers can use Lerna together with Nx and Turborepo to build powerful, scalable monorepo setups that outperform traditional polyrepo structures.

Why Lerna Still Holds Strong Relevance in 2025
The Evolution of Lerna in JavaScript Monorepo Tooling

Lerna has been one of the foundational tools in the JavaScript monorepo ecosystem for years. Originally designed to manage multi-package repositories, Lerna made it easier to link local packages, handle consistent versioning, and execute commands across packages. Despite newer tools gaining popularity, Lerna remains a valuable asset in a monorepo strategy, particularly when integrated with Nx.

The latest versions of Lerna allow it to use Nx under the hood through the "useNx": true flag in lerna.json, making it far more performant. This hybrid setup lets developers leverage Nx’s computation caching, task orchestration, and affected project analysis without abandoning Lerna’s simpler package management workflows. This symbiosis means teams can modernize their monorepos without undergoing a full migration.

Setting the Stage: The Key Benefits of Monorepo Architectures
Centralization, Consistency, and Collaboration

Before diving deeper into tooling, it’s essential to understand why monorepos matter. Large teams working on microservices, UI components, backend APIs, and shared utilities often suffer from code duplication, dependency drift, inconsistent tooling, and siloed CI/CD pipelines when using multiple repositories.

Monorepos solve this by offering:

  • Unified dependency management: One package.json or lockfile to rule them all. This eliminates version mismatches and streamlines updates across packages.

  • Atomic commits across multiple packages: Developers can refactor interfaces and logic shared across libraries and apps with full confidence that all consumers are updated simultaneously.

  • Shared tooling and standards: ESLint, Prettier, Jest, TypeScript configs can be managed centrally, reducing setup and ensuring consistency.

  • Optimized CI/CD performance: With the help of tools like Nx and Turborepo, monorepos support intelligent task execution, drastically reducing build and test times.

As engineering teams scale, monorepos become vital for controlling complexity, accelerating feature delivery, and simplifying cross-project collaboration.

Overview: Lerna, Turborepo, and Nx in the Monorepo Ecosystem
The Three Core Tools for Monorepo Management

Let’s briefly explore what each tool brings to the table in modern monorepo development workflows.

Lerna: The Package Manager and Versioning Tool

Lerna is best known for its ability to manage multiple interdependent packages within a single monorepo. It provides powerful capabilities:

  • Bootstrapping: Installs dependencies and links local packages.

  • Versioning: Supports fixed and independent versioning models, making it easy to release updated packages to registries like npm.

  • Executing scripts: You can run commands like lerna run build across multiple packages in parallel or in sequence.

With "useNx": true, Lerna can now delegate task execution and project graph analysis to Nx, giving it modern performance capabilities.

Turborepo: Caching and Incremental Builds for Speed

Turborepo, by Vercel, is a monorepo build system built for speed. It focuses on:

  • Incremental builds using content-based hashing

  • Pipeline orchestration through a configuration-driven approach

  • Zero-config support for projects using Next.js, React, and Node.js

Turborepo reduces build times significantly, especially when working with JS/TS projects. While it lacks native multi-language support and package publishing tools, it excels in developer experience and speed for frontend-heavy stacks.

Nx: The Powerhouse for Enterprise-Scale Monorepos

Nx is a full-featured build system and monorepo management toolkit that:

  • Builds and tests only affected packages

  • Maintains a dependency graph to track relationships between apps and libs

  • Offers distributed computation caching

  • Provides an extensible plugin system for React, Node, NestJS, Go, Rust, and more

It is especially suitable for enterprise-grade monorepos with thousands of packages, large-scale CI/CD pipelines, and complex architecture.

Combining Lerna with Nx (and Turborepo) for Performance and Scalability
Why Use Lerna with Nx?

Many engineering teams already use Lerna in existing projects. Instead of migrating everything to Nx or Turborepo, integrating Nx with Lerna allows developers to:

  • Keep using familiar Lerna CLI commands like lerna bootstrap, lerna version, and lerna publish

  • Gain access to Nx’s caching, task runner, and dependency graph

  • Avoid full rewrites or major changes to project structure

By simply enabling "useNx": true in lerna.json, you unlock powerful performance gains. Nx takes over task execution, applies remote and local caching, and only runs tasks on changed packages, reducing build and test times by up to 90%.

Optional Integration with Turborepo

While Lerna + Nx is a complete setup, Turborepo can be added to projects to experiment with its build pipelines or integrate with Vercel’s CI/CD system.

Turborepo allows task pipelines to be defined in turbo.json, using cache and dependency-based execution. It’s best suited for JavaScript-based workflows that prioritize simple developer experience and fast iteration over complex project graphs.

Step-by-Step Guide: Setting Up Lerna + Nx + (Turborepo Optional)
1. Initialize Your Lerna Project

Start with a simple Lerna monorepo:

csharp 

npx lerna init

This generates:

  • lerna.json ,  configures Lerna behavior

  • package.json ,  defines root-level scripts and dependencies

  • packages/ ,  directory for individual apps and libraries

2. Install and Enable Nx in Lerna

Install Nx:

css 

npm install --save-dev nx

Modify your lerna.json file:

json 

{

  "useNx": true,

  "packages": ["packages/*"],

  "version": "independent"

}

Generate an Nx workspace:

csharp 

npx nx init

This creates nx.json, workspace.json, and other configuration files that Nx uses to manage your project graph and task runners.

Define cacheable tasks in nx.json:

json 

{

  "tasksRunnerOptions": {

    "default": {

      "runner": "nx/tasks-runners/default",

      "options": {

        "cacheableOperations": ["build", "test", "lint"]

      }

    }

  }

}

3. Add Optional Turborepo Support

Install:

css 

npm install --save-dev turbo

Create turbo.json:

json 

{

  "pipeline": {

    "build": {

      "dependsOn": ["^build"],

      "outputs": ["dist/**"]

    },

    "test": {

      "outputs": []

    }

  }

}

This enables Turborepo to execute tasks incrementally based on dependency graphs and caching logic.

The Developer Payoff: Real Benefits in Day-to-Day Work
Faster CI/CD with Caching

With Nx and Turborepo integrated, your monorepo leverages local and remote caching to avoid redundant work. Builds, tests, and lint operations that haven’t changed are skipped or reused, drastically reducing pipeline execution time.

Smarter Developer Workflows

With Nx’s affected commands, developers can run:

nginx 

npx nx affected:build

This runs builds only on changed packages and their dependents, no need to build the entire monorepo.

Maintainable Architecture

A well-structured monorepo with Lerna + Nx allows modularity, code reuse, and easier cross-team collaboration. Apps and libraries are loosely coupled but share a centralized configuration and tooling setup.

Lerna vs Nx vs Turborepo: Choosing the Right Monorepo Tooling
When to Choose Each Tool
  • Lerna alone is great for managing packages and publishing, but lacks advanced performance features.

  • Nx is best for scalable, enterprise-grade projects with language diversity, testing strategies, and CI optimizations.

  • Turborepo is ideal for small to medium teams focused on web development, prioritizing speed and simplicity.

  • Lerna + Nx offers the best of both worlds, familiar CLI, fast task execution, dependency-aware operations, and modern caching.

Best Practices to Maximize Monorepo Success
Follow These Guidelines
  • Use Yarn/npm/pnpm workspaces for dependency hoisting and package resolution.

  • Enable caching in Nx for build, test, lint, e2e.

  • Visualize dependencies using nx graph for better architectural insights.

  • Use nx format:check and nx lint to enforce consistent code quality across the repo.

  • Keep apps and libraries modular and isolated for better maintainability.

Final Thoughts: Unlocking Monorepo Excellence with Lerna + Nx + Turborepo

By combining Lerna, Nx, and optionally Turborepo, developers can unlock the full potential of monorepos. Whether you’re scaling a single product or managing an enterprise suite of apps and shared libraries, this trio of tools gives you:

  • Speed through intelligent caching and affected builds

  • Clarity through project graphs and dependency management

  • Power to maintain modular, testable, versioned code at scale

This is not just about tools, it’s about crafting a monorepo strategy that aligns with your team’s growth, productivity, and code quality goals.