• Discover
  • Collections
  • Board
  • Create
  • Profile
  • Settings
Paths

Initializing a Turborepo Project

Initializing a Turborepo Project

2 min read

Overview

This lesson provides a hands-on guide to initializing a new Turborepo monorepo. We'll start from scratch and explore the basic structure created by the Turborepo CLI, setting the foundation for our migration.

Key Points

  • Using create-turbo: The easiest way to start is with the official initializer, which sets up a basic monorepo structure with example apps and packages.

  • Initial Project Structure: A newly created Turborepo typically includes:

  • A root package.json defining workspaces.

  • A turbo.json for pipeline configuration.

  • An apps directory (e.g., web, docs).

  • A packages directory (e.g., ui, eslint-config, tsconfig).

  • Defining Workspaces in package.json: The workspaces array in the root package.json tells your package manager (npm, Yarn, pnpm) which directories contain sub-projects.

  • Adding New Workspaces: To add a new application or package, simply create its directory within apps/ or packages/ and ensure its name is included in the root package.json workspaces array.

Quick Example

To initialize your Turborepo:

bash npx create-turbo@latest -- --appName=my-next-app --packageManager=pnpm

After initialization, your package.json might look like this:

json
{ "name": "my-monorepo", "version": "1. 0. 0", "private": true, "workspaces": ```json [ "apps/*", "packages/*" ]

}





## Summary

Initializing a Turborepo with `create-turbo` provides a solid starting point. Understanding the roles of the root `package.json`'s `workspaces` and `turbo.json` is fundamental for managing your monorepo's projects and tasks effectively.
End of lesson
👏Well done!
Previous Lesson
Quiz: Module 1: Understanding the Monorepo Ecosystem
Next Lesson
Migrating Next.js Applications to Turborepo

Course Content

0% Complete0/12 Lessons

Introduction to Monorepos and Turborepo

Core Concepts of Turborepo

Planning Your Monorepo Migration

Quiz

Initializing a Turborepo Project

Migrating Next.js Applications to Turborepo

Integrating Shared UI Components and Utilities

Quiz

Course Content

0% Complete0/12 Lessons

Introduction to Monorepos and Turborepo

Core Concepts of Turborepo

Planning Your Monorepo Migration

Quiz

Initializing a Turborepo Project

Migrating Next.js Applications to Turborepo

Integrating Shared UI Components and Utilities

Quiz