create-turbo 命令行

使用 Turborepo 最简单的方法是使用 create-turbo。使用这个 CLI 工具可以快速开始构建新的单体仓库,一切都为你设置好了。

Terminal
npx create-turbo@latest

从示例开始

社区精心策划了一系列示例,展示了使用 Turborepo 与常见工具和库的方法。要使用其中一个示例引导你的单体仓库,请使用 --example 标志:

Terminal
npx create-turbo@latest --example [example-name]

使用以下任何示例名称:

核心团队维护的示例

以下示例由 Turborepo 核心团队维护。依赖项保持尽可能最新,并接受和处理针对这些示例的 GitHub 问题。

NameDescription
BasicBasic monorepo example with two Next.js applications
Kitchen sinkMultiple frameworks, both frontend and backend
Non-monorepoA standalone application using Turborepo
Shell commandsA nearly empty Turborepo - useful for creating reproductions for GitHub Issues
SvelteKitMonorepo with multiple SvelteKit apps sharing a UI Library
TailwindCSSMonorepo with multiple Next.js apps sharing a UI library built with TailwindCSS

社区维护的示例

社区精心策划了一系列示例,展示了使用 Turborepo 与常见工具和库的方法。要使用其中一个示例引导你的单体仓库,请使用 --example 标志:

NameDescription
Design SystemUnify your site's look and feel by sharing a design system across multiple apps
AngularMinimal Turborepo example for learning the fundamentals
Yarn BerryMonorepo example using Yarn Berry (Yarn 3)
ChangesetsConfigured to publish packages via Changesets
DockerMonorepo with an Express API and a Next.js App deployed with Docker utilizing turbo prune
GatsbyMonorepo with a Gatsby.js and a Next.js app both sharing a UI Library
Nest.jsMonorepo with Nest.js
npm workspacesMonorepo example using NPM workspaces
PrismaMonorepo with a Next.js App fully configured with Prisma
React NativeSimple React Native & Next.js monorepo with a shared UI library
RollupMonorepo with a single Next.js app sharing a UI library bundled with Rollup
Solid.jsMonorepo example with SolidJS applications
typeormMonorepo with a Next.js App fully configured with typeorm
ViteMonorepo with multiple Vanilla JS apps bundled with Vite, sharing a UI Library
Vite + ReactMonorepo example with Vite and React
VitestMonorepo example with Vitest for testing
Vue/NuxtMonorepo with Vue and Nuxt, sharing a UI Library
YarnMonorepo example using Yarn workspaces

使用社区示例

你也可以通过使用 GitHub URL 来使用自定义入门项目或示例。这对于使用你自己的自定义入门项目或来自社区的示例很有用。

Terminal
npx create-turbo@latest --example [github-url]

选项

Terminal
-m, --package-manager 使用的包管理器 (选项:"npm", "yarn", "pnpm", "bun")

--skip-install: 创建项目后不运行包管理器安装 (默认:false)

--skip-transforms: 创建项目后不运行任何代码转换 (默认:false)

--turbo-version <version>: 使用特定版本的 turbo (默认:最新版)

-e, --example [name]|[github-url]: 用于引导应用程序的示例。你可以使用官方 Turborepo 仓库中的示例名称或 GitHub URL。URL 可以使用任何分支和/或子目录

-p, --example-path <path-to-example>: 在极少数情况下,你的 GitHub URL 可能包含带有斜杠的分支名称(例如 bug/fix-1)和示例的路径(例如 foo/bar)。在这种情况下,你必须单独指定示例的路径:--example-path foo/bar

-v, --version: 输出当前版本

-h, --help: 显示命令帮助