create-expo-app

用于创建新 Expo 和 React Native 项目的命令行工具。


For the complete documentation index, see llms.txt. Use this file to discover all available pages.

create-expo-app 是一个命令行工具,用于创建和设置新的 Expo 和 React Native 项目。该工具通过提供各种模板简化了初始化过程,使用户可以快速开始,而无需手动配置。

创建新项目

🌐 Create a new project

要创建新项目,请运行以下命令:

🌐 To create a new project, run the following command:

Terminal
npx create-expo-app@latest --template default@sdk-55

注意: 在 SDK 55 过渡期间,不带 --template 标志的 create-expo-app@latest 会创建一个 SDK 54 项目。如果你计划在物理设备上使用 Expo Go,请使用 SDK 54 项目。否则,请使用 --template default@sdk-55 创建一个 SDK 55 项目。

运行上述命令会提示你输入项目的应用名称。这个应用名称也会在应用配置的 name 属性中使用。

🌐 Running the above command will prompt you to enter the app name of your project. This app name is also used in the app config's name property.

Terminal
What is your app named? my-app

选项

🌐 Options

使用以下选项自定义命令行为。

🌐 Uses the following options to customize the command behavior.

--yes

使用默认选项创建新项目。

🌐 Uses the default options to create a new project.

--no-install

跳过安装 npm 依赖或 CocoaPods。

🌐 Skips installing npm dependencies or CocoaPods.

--no-agents-md

跳过生成 AGENTS.mdCLAUDE.md.claude/settings.json。默认情况下,create-expo-app 会生成这些文件,以便 AI 编码代理(如 Claude Code)能够自动获取特定于 Expo 的上下文以及已配置的 expo 技能插件。生成的 AGENTS.md 会指向与你的项目 SDK 版本匹配的版本化 Expo 文档。

🌐 Skips generating AGENTS.md, CLAUDE.md, and .claude/settings.json. By default, create-expo-app generates these files so AI coding agents (such as Claude Code) have Expo-specific context and the expo skills plugin configured automatically. The generated AGENTS.md points to the versioned Expo docs matching your project's SDK version.

--template

使用 Node 包管理器 运行 create-expo-app 会初始化并设置一个使用默认模板的新 Expo 项目。

🌐 Running create-expo-app with a Node Package Manager initializes and sets up a new Expo project using the default template.

你可以使用 --template 选项来选择以下模板之一,或者将其作为参数传递给该选项。例如,--template default

🌐 You can use the --template option to select one of the following templates or pass it as an argument to the option. For example, --template default.

信息 想要更多模板?请查看 --example 选项,通过其中的示例应用初始化你的项目,这些示例展示了特定的功能和集成。

模板描述
default默认模板。设计用于构建多屏应用。包括推荐工具,如 Expo CLI、Expo Router 库和已启用的 TypeScript 配置。适用于大多数应用。
blank安装最低所需的 npm 依赖,而不配置导航。
blank-typescript一个启用 TypeScript 的空白模板。
tabs安装并配置基于文件的路由,同时启用 Expo Router 和 TypeScript。
bare-minimum一个带有本地目录(androidios)的空白模板。设置过程中会运行 npx expo prebuild

--example

使用此选项可使用来自 expo/examples 的示例初始化项目。

🌐 Use this option to initialize a project using an example from expo/examples.

例如:

🌐 For example:

  • 运行 npx create-expo-app --example with-router 会使用 Expo Router 库设置一个项目
  • 运行 npx create-expo-app --example with-react-navigation 会创建一个类似默认模板的项目,但配置为使用纯 React Navigation 库

--version

打印版本号并退出。

🌐 Prints the version number and exits.

--help

打印可用选项列表并退出。

🌐 Prints the list of available options and exits.

节点包管理器支持

🌐 Node Package Managers support

使用 create-expo-app 创建新项目还会处理为特定的 Node 包管理器设置所需的额外配置。

🌐 Creating a new project with create-expo-app also handles setting up additional configuration needed for a specific Node Package Manager.

如果你正在从一个包管理器迁移到另一个包管理器,你需要在项目中手动进行额外的配置。如果你正在使用 EAS,你还需要手动为项目配置任何额外所需的步骤。

每个包管理器的所有其他步骤都列在下面。

🌐 All the additional steps for each package manager are listed below.

npm

本地安装

🌐 Local installation

npm 是作为 Node.js 安装的一部分安装的。有关安装说明,请参阅 Node.js 文档

🌐 npm is installed as part of Node.js installation. See Node.js documentation for installation instructions.

EAS 安装

🌐 EAS installation

如果项目目录包含 package-lock.json,则默认支持。

🌐 Supported by default if the project directory contains package-lock.json.

Yarn 1(经典)

🌐 Yarn 1 (Classic)

本地安装

🌐 Local installation

Yarn 1(经典版)通常作为 npm 的全局依赖安装。有关安装说明,请参阅 Yarn 1 文档

🌐 Yarn 1 (Classic) is usually installed as a global dependency of npm. See Yarn 1 documentation for installation instructions.

EAS 安装

🌐 EAS installation

如果项目目录包含 yarn.lock,则默认支持。

🌐 Supported by default if the project directory contains yarn.lock.

Yarn 2+ (Modern)

本地安装

🌐 Local installation

请参阅 Yarn 文档 获取安装说明。

🌐 See Yarn documentation for installation instructions.

Yarn 2 及以上版本的包管理方式与 Yarn 1 不同。Yarn 2 及以上版本的核心变化之一是 Plug'n'Play (PnP) 节点链接模型,但它与 React Native 不兼容。

🌐 Yarn 2+ handles package management differently than Yarn 1. One of the core changes in Yarn 2+ is the Plug'n'Play (PnP) node linking model that does not work with React Native.

默认情况下,使用 create-expo-app 和 Yarn 2+ 创建的项目会使用 nodeLinker 并将其值设置为 node-modules 来安装依赖。

🌐 By default, a project created with create-expo-app and Yarn 2+ uses nodeLinker with its value set to node-modules to install dependencies.

.yarnrc.yml
nodeLinker: node-modules

EAS 安装

🌐 EAS installation

在 EAS 上使用现代 Yarn 需要在构建中启用 Corepack。在 eas.json 的构建配置中将 corepack 设置为 true

🌐 Yarn Modern on EAS requires enabling Corepack for the build. Set corepack to true in your build profile in eas.json:

eas.json
{ "build": { "production": { "corepack": true } } }

然后,在你项目的 package.json 中使用 packageManager 字段固定 Yarn 版本。在本地运行 yarn set version <version> 会为你更新此字段:

🌐 Then, pin the Yarn version in your project's package.json using the packageManager field. Running yarn set version <version> locally will update this field for you:

package.json
{ "packageManager": "yarn@4.14.1" }

在添加上述两种配置后,当 EAS 安装依赖时,Corepack 会自动下载并使用固定的 Yarn 版本。

🌐 After adding both of the above configurations, Corepack automatically downloads and uses the pinned Yarn version when EAS installs dependencies.

pnpm

本地安装

🌐 Local installation

需要安装 Node.js。请参阅 pnpm 文档 了解安装说明。

🌐 Requires installing Node.js. See pnpm documentation for installation instructions.

默认情况下,使用 create-expo-app 和 pnpm 创建的项目使用 nodeLinker 并将其值设置为 hoisted 来安装依赖。

🌐 By default, a project created with create-expo-app and pnpm uses nodeLinker with its value set to hoisted to install dependencies.

pnpm-workspace.yaml
nodeLinker: hoisted

信息SDK 54 及更高版本中,Expo 支持独立安装,如果你更喜欢使用独立依赖,可以删除 nodeLinker 设置。

EAS 安装

🌐 EAS installation

如果项目目录包含 pnpm-lock.yaml,则默认支持。

🌐 Supported by default if the project directory contains pnpm-lock.yaml.

Bun

有关使用 bun 创建新的 Expo 项目、从其他包管理器迁移以及与 EAS 一起使用的详细信息,请参阅 Bun 指南。

🌐 See Bun guide for details on creating a new Expo project with bun, migration from another package manager, and usage with EAS.