DEV Community

Libme
Libme

Posted on

pnpm Workspaces vs Turborepo vs Nx: Do You Need a Monorepo Build Tool?

Short answer: if your monorepo has fewer than roughly a handful of packages and CI finishes in a few minutes, pnpm workspaces alone are enough. Add Turborepo when you want cached, dependency-ordered task running with almost no configuration. Reach for Nx when you need project-graph tooling, code generators, or enforced module boundaries, and you accept a larger surface area to learn.

This post is written for the moment you search "do I need Turborepo" after your CI time started creeping up. Tool details are as of November 2026; the decision logic should survive the next releases.

What do pnpm workspaces already give you?

A surprising amount. Declare the packages and you get linked local dependencies, a single lockfile, and recursive or filtered script execution.

# pnpm-workspace.yaml
packages:
  - "apps/*"
  - "packages/*"
Enter fullscreen mode Exit fullscreen mode
# run "build" in every package, dependencies first (topological order)
pnpm -r build

# only the web app and everything it depends on
pnpm --filter web... build

# only packages changed since main, plus their dependents
pnpm --filter "...[origin/main]" test
Enter fullscreen mode Exit fullscreen mode

That last command is the one people miss. The ...[origin/main] selector gives you "affected only" CI with no extra tool. What tripped me up the first time: in CI the checkout is shallow by default, so the git ref doesn't exist and the filter silently matches nothing or errors. Fetch full history (fetch-depth: 0 in GitHub Actions) or fetch the base branch explicitly.

What pnpm does not give you: a cache. Every run re-executes every selected task, even if inputs are identical to the last run.

Takeaway: pnpm workspaces already provide ordering and "changed since main" filtering; what they lack is a task-output cache.

What does Turborepo add on top?

Turborepo is a task runner layered over your existing package manager workspaces. You describe tasks and their inputs and outputs, and it skips work whose inputs hash identically to a previous run, restoring the saved outputs instead.

{
  "$schema": "https://turbo.build/schema.json",
  "tasks": {
    "build": {
      "dependsOn": ["^build"],
      "outputs": ["dist/**"]
    },
    "test": {
      "dependsOn": ["build"]
    },
    "lint": {}
  }
}
Enter fullscreen mode Exit fullscreen mode

^build means "build my dependencies first". outputs tells Turborepo what to cache; forgetting it is the classic mistake, where a task is marked as a cache hit but the dist/ folder never reappears and downstream tasks fail with missing-module errors.

Caching is local by default. Sharing the cache across CI runs and teammates requires a remote cache, which Vercel offers as a hosted service and which you can also self-host via the documented remote cache API. Without a remote cache, a fresh CI runner starts cold every time, so you only benefit if you persist the local cache directory yourself.

The honest drawback: the cache is only as correct as your declared inputs. An environment variable that changes build output but isn't listed under env or globalEnv produces stale cache hits, which are far more annoying to debug than slow builds.

If you want the lowest-effort way to add caching and ordering to an existing pnpm workspace, Turborepo is the one that needs a single turbo.json and almost no restructuring.

Takeaway: Turborepo's value is the cache, and the cache is only trustworthy if you declare every input and output honestly.

When is Nx worth the extra weight?

Nx covers the same caching and affected-project ground, but adds a project graph you can visualize, code generators, plugins that infer tasks from tooling config, and lint rules that enforce which projects may import which. Remote caching is available through Nx Cloud.

That boundary enforcement is the feature that justifies it. In a repo with several teams or a messy dependency tree, "the billing package must never import from the admin app" stops being a code-review convention and becomes a failing lint check.

The cost is conceptual. Nx has more configuration surfaces (nx.json, per-project config, plugins), and upgrades often involve its migration commands. For a three-person team shipping one app and two libraries, much of that is overhead you will never use.

If your problem is architectural control across many packages and teams rather than just build speed, Nx is the one that treats the dependency graph as a first-class, enforceable thing.

Takeaway: choose Nx for module boundaries and generators at scale, not for caching alone.

Which one should you pick? A decision table

Situation pnpm workspaces only Turborepo Nx
2-5 packages, CI under a few minutes Best fit Unnecessary Overkill
Slow CI from repeated identical builds Not enough Strong fit Strong fit
Need cache shared across CI and laptops No Yes, with remote cache Yes, with Nx Cloud or alternatives
Enforce import boundaries between packages Needs separate lint rules Not built in Built in
Code generators and scaffolding Hand-rolled scripts Basic generator support Extensive
Learning curve Lowest Low Highest
Non-JavaScript packages in the repo Awkward Possible via scripts Possible via plugins

How do you decide without guessing?

Measure before adopting anything. Find out what share of your CI runs repeat work that hasn't changed:

  1. Time your slowest job on a typical pull request.
  2. Try pnpm --filter "...[origin/main]" first. If most PRs touch one package, this alone often cuts the work substantially.
  3. Only if filtered runs are still slow, add Turborepo and enable a remote cache.
  4. Only if you hit boundary or scaffolding problems, evaluate Nx.

Each step is reversible. Moving from pnpm workspaces to Turborepo is mostly adding a config file; the packages themselves do not change.

Takeaway: adopt tools in order of the problem you can actually measure, not the one the docs describe best.

FAQ

Do I need Turborepo if I already use pnpm workspaces?

No, not for correctness. pnpm workspaces handle linking, ordering, and filtering by changed packages. You need Turborepo only when repeated identical task runs are costing you meaningful CI time.

Is Nx or Turborepo better for a small team?

For a small team focused on faster builds, Turborepo is usually less to learn and configure. Nx pays off when you need enforced module boundaries or generators across many packages.

Why does my Turborepo cache hit but the build output is missing?

Your task's outputs array is probably missing or wrong, so Turborepo has nothing to restore. List the build directory explicitly, such as dist/**, and make sure env vars affecting output are declared.

Bottom line

Start with pnpm workspaces and the ...[origin/main] filter; most small teams never need more. Add Turborepo when identical rebuilds are the measured bottleneck and you can maintain honest inputs and outputs. Choose Nx when the real problem is controlling how dozens of packages depend on each other, and budget time to learn it.

Related reading

Top comments (0)