Setting up Turborepo in an existing (or new) JavaScript/TypeScript monorepo is straightforward. Turborepo integrates seamlessly with popular package managers that support workspaces, such as Yarn Workspaces, pnpm Workspaces, and npm Workspaces. The first step typically involves defining your workspaces in your package manager's configuration file (e.g., pnpm-workspace.yaml or package.json's workspaces field).
Next, you'll install turbo as a development dependency. The core configuration lives in a turbo.json file at the root of your monorepo. This file defines your pipeline, specifying how tasks (like build, test, lint) should be run, what files they output, and which other tasks they depend on. For example, a build task might depend on a lint task. Turborepo then orchestrates these tasks using the turbo run command, automatically applying caching and parallelism based on your configuration and the project's dependencies.
json{ "$schema": "https://turbo.build/schema.json", "pipeline": { "build": { "dependsOn": ["^build"], "outputs": [".next/**", "dist/**"] }, "lint": {}, "dev": { "cache": false, "persistent": true } } }
This minimal turbo.json tells Turborepo about your build, lint, and dev scripts, defining dependencies and output files for efficient caching.