# Create React App

**Create React App**（CRA）曾是一个命令行工具，于2016年7月首次发布，只需一条命令 `npx create-react-app my-app`，即可生成一个完整配置的单页React应用，包含开发服务器、代码检查和生产构建。<sup>[1](https://legacy.reactjs.org/blog/2016/07/22/create-apps-with-no-configuration.html)</sup><sup> • </sup><sup>[2](https://github.com/react/create-react-app/blob/main/README.md)</sup> React团队于2025年2月14日正式弃用该工具，如今建议使用Next.js、React Router或Expo等框架，或[Vite](https://www.edgepedia.org/zh/vite)、Parcel、Rsbuild等构建工具来启动新项目。<sup>[3](https://react.dev/blog/2025/02/14/sunsetting-create-react-app)</sup>

| 关键事实 | 详情 |
|---|---|
| 首次发布 | 2016年7月22日由丹·阿布拉莫夫（Dan Abramov）宣布，作为一种官方支持的、无需配置即可创建单页React应用的方式<sup>[1](https://legacy.reactjs.org/blog/2016/07/22/create-apps-with-no-configuration.html)</sup> |
| 核心命令 | `npx create-react-app my-app`，然后 `npm start`（开发服务器运行于 http://localhost:3000/），以及 `npm run build` 生成压缩的生产包<sup>[2](https://github.com/react/create-react-app/blob/main/README.md)</sup> |
| 底层实现 | webpack、Babel、ESLint等工具被整合为单一的构建依赖 `react-scripts`，无需任何配置<sup>[2](https://github.com/react/create-react-app/blob/main/README.md)</sup> |
| 逃生通道 | `eject` 命令可将所有配置和构建依赖复制到项目中，代价是需自行维护<sup>[2](https://github.com/react/create-react-app/blob/main/README.md)</sup> |
| 巅峰时期 | 其代码仓库称其为2017至2021年间启动React项目的关键工具之一<sup>[4](https://github.com/react/create-react-app)</sup> |
| 弃用 | 2025年2月14日弃用；现在安装会打印弃用警告，工具以维护模式继续运行，并发布了兼容React 19的版本<sup>[3](https://react.dev/blog/2025/02/14/sunsetting-create-react-app)</sup> |
| 后继方案 | 框架（Next.js、React Router、Expo）或构建工具（Vite、Parcel、Rsbuild），各自均有官方迁移指南<sup>[3](https://react.dev/blog/2025/02/14/sunsetting-create-react-app)</sup> |

## 目的与设计

2016年Create React App问世时，构建一个新的React应用尚无明确路径。开发者必须自行安装并连接多个工具，才能支持JSX、代码检查和热重载等基本功能，而要正确完成这些配置颇为棘手。社区用样板项目填补了这一空白，但样板项目难以更新，其碎片化也使React难以推出新功能。<sup>[3](https://react.dev/blog/2025/02/14/sunsetting-create-react-app)</sup>

Create React App通过将多个工具整合为单一推荐配置解决了这一问题。这为应用提供了一条简单的升级路径，使其能获得新的工具特性，也让React团队能够将非同小可的工具变更——例如快速刷新（Fast Refresh）支持和React Hooks的代码检查规则——部署给尽可能广泛的受众。React团队指出，这一模式已足够流行，如今整整一类工具都采用相同的工作方式。<sup>[3](https://react.dev/blog/2025/02/14/sunsetting-create-react-app)</sup>

**一个依赖，零配置。** 该项目宣称的理念是：一个依赖、无需配置、无锁定。创建的应用包含React、JSX、ES6、[TypeScript](https://www.edgepedia.org/zh/typescript)和Flow语法支持；自动添加前缀的CSS；一个会在出现常见错误时发出警告的实时开发服务器；一个带覆盖率报告的单元测试运行器；以及一个生产构建脚本，可将[JavaScript](https://www.edgepedia.org/zh/javascript)、CSS和图片打包，文件名带内容哈希并生成源码映射。<sup>[2](https://github.com/react/create-react-app/blob/main/README.md)</sup> 最初的公告将其描述为无需配置的现代构建方案，底层使用webpack和Babel，控制台输出经过调校，力求精简。<sup>[1](https://legacy.reactjs.org/blog/2016/07/22/create-apps-with-no-configuration.html)</sup>

**弹出（Ejecting）。** 由于工具已按特定方式预配置，需要更多自定义的项目可以运行一条 `eject` 命令，将所有配置和构建依赖从 `react-scripts` 直接移入项目。弹出后，配置归开发者所有并需自行维护。<sup>[2](https://github.com/react/create-react-app/blob/main/README.md)</sup>

## 使用方式

创建应用需要在本地开发机上安装Node.js（最终文档中要求版本14或更高，但服务器上不需要）。标准流程为：<sup>[5](https://create-react-app.dev/docs/getting-started/)</sup>

```
npx create-react-app my-app
cd my-app
npm start
```

开发服务器在 http://localhost:3000/ 提供应用，`npm run build` 生成可部署的压缩生产包。<sup>[2](https://github.com/react/create-react-app/blob/main/README.md)</sup> 应用可通过 `--template [template-name]` 从模板启动，包括官方TypeScript模板；CLI会根据调用它的工具选择npm或Yarn来安装依赖。<sup>[5](https://create-react-app.dev/docs/getting-started/)</sup> 该工具支持macOS、Windows和Linux。<sup>[2](https://github.com/react/create-react-app/blob/main/README.md)</sup>

## 弃用

2025年2月14日，React团队宣布弃用Create React App，不再建议将其用于新应用。现在安装新应用会打印弃用警告，指向react.dev上最新React框架列表，每次安装显示一次；Create React App网站和GitHub仓库也添加了弃用通知。该工具以维护模式继续工作，并发布了兼容React 19的新版本。<sup>[3](https://react.dev/blog/2025/02/14/sunsetting-create-react-app)</sup>

这一决定有两个驱动因素。第一，尽管Create React App让入门变得容易，但它存在局限，难以构建高性能的生产应用；原则上可以通过将其演进为框架来解决。第二，该项目没有活跃的维护者，而许多现有框架已经解决了这些问题。<sup>[3](https://react.dev/blog/2025/02/14/sunsetting-create-react-app)</sup> 仓库README直言项目处于长期停滞状态，建议迁移到React框架，并补充说继续现有教程无妨，但不建议在Create React App上启动生产应用。<sup>[4](https://github.com/react/create-react-app)</sup>

与React 19的兼容问题让新用户直观感受到了困境。从React 19发布开始，运行 `create-react-app my-app` 会在项目安装过程中产生严重的NPM错误：CRA总是安装最新的React版本，而其默认模板固定了 `@testing-library/react@13`，后者声明了对React 18的对等依赖。NPM作为CRA安装的默认包管理器，在对等依赖不匹配时会立即报错，导致项目创建失败。<sup>[6](https://github.com/facebook/create-react-app/issues/17004)</sup>

## 迁移路径

React团队建议使用框架创建新应用。其推荐的所有框架都支持客户端渲染和单页应用，无需服务器即可部署到CDN或静态托管服务。对于现有应用，团队提供了指向Next.js、React Router的框架采用路径和Expo Router的迁移指南。<sup>[3](https://react.dev/blog/2025/02/14/sunsetting-create-react-app)</sup> 当前React文档将Next.js（App Router）、React Router v7搭配Vite，以及用于原生应用的Expo列为推荐的全栈框架。<sup>[7](https://react.dev/learn/creating-a-react-app)</sup>

对于有特殊限制的应用，或希望构建自己的框架、从零学习React工作原理的开发者，团队建议使用构建工具Vite、Parcel或Rsbuild自行搭建自定义配置，并发布了各自的迁移指南以及从零构建React应用的新文档。<sup>[3](https://react.dev/blog/2025/02/14/sunsetting-create-react-app)</sup> 公告中提供的一条经验法则是：如果你的应用需要路由，那么集成了路由、数据获取和代码分割的框架很可能更适合你。<sup>[3](https://react.dev/blog/2025/02/14/sunsetting-create-react-app)</sup>

## 该模式的局限

Create React App及类似的构建工具让入门变得容易：运行 `npx create-react-app my-app` 之后，你就有了开发服务器、代码检查和生产构建。这套配置缺少的是大多数生产应用所需的工具，例如路由、数据获取和代码分割，也不涉及渲染策略。服务端渲染可以在CI服务器的构建时运行，生成静态站点，也可以在Web服务器的运行时运行；Chrome团队一直鼓励采用静态或服务端渲染而非完全客户端渲染，因为这能减少用户在看到内容之前必须下载和解析的JavaScript量，不仅仅是为了SEO。<sup>[3](https://react.dev/blog/2025/02/14/sunsetting-create-react-app)</sup>

单一依赖的设计也带来了自定义成本。webpack配置位于 `react-scripts` 内部，对项目隐藏，因此修改它需要弹出，而弹出即终结了零配置的保证。<sup>[2](https://github.com/react/create-react-app/blob/main/README.md)</sup>

## 历史

Create React App于2016年7月22日由React团队开发者丹·阿布拉莫夫在React博客上宣布，作为一种官方支持的创建单页React应用的新方式。<sup>[1](https://legacy.reactjs.org/blog/2016/07/22/create-apps-with-no-configuration.html)</sup> 2016年的早期版本增加了Yarn支持、用于静态资源的 `public` 文件夹、通过 `.env` 文件设置环境变量默认值，以及持续集成代码检查。<sup>[8](https://github.com/react/create-react-app/blob/main/CHANGELOG-0.x.md)</sup> 公告中感谢丹·阿布拉莫夫创建了该工具，感谢乔·哈达德（Joe Haddad）、伊恩·施密茨（Ian Schmitz）、布罗迪·麦基（Brody McKee）等许多人多年来的维护。<sup>[3](https://react.dev/blog/2025/02/14/sunsetting-create-react-app)</sup> 最后一个值得注意的发布系列5.0.1是一个维护版本，改进了与React 18的兼容性。<sup>[9](https://github.com/react/create-react-app/releases)</sup>

## References

1. [Create Apps with No Configuration – React Blog, July 22, 2016](https://legacy.reactjs.org/blog/2016/07/22/create-apps-with-no-configuration.html)
2. [create-react-app README, GitHub](https://github.com/react/create-react-app/blob/main/README.md)
3. [Sunsetting Create React App – React, February 14, 2025](https://react.dev/blog/2025/02/14/sunsetting-create-react-app)
4. [react/create-react-app repository, GitHub](https://github.com/react/create-react-app)
5. [Getting Started | Create React App](https://create-react-app.dev/docs/getting-started/)
6. [Umbrella: CRA breaks with React 19, and CRA needs deprecation notices · Issue #17004](https://github.com/facebook/create-react-app/issues/17004)
7. [Creating a React App – React](https://react.dev/learn/creating-a-react-app)
8. [create-react-app CHANGELOG-0.x, GitHub](https://github.com/react/create-react-app/blob/main/CHANGELOG-0.x.md)
9. [Releases · react/create-react-app, GitHub](https://github.com/react/create-react-app/releases)

---
*Initially written Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 软件与编程 › Development tools and collaboration infrastructure › Build, deployment, and development tooling › JavaScript bundlers and build tooling

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/create-react-app

English original: https://www.edgepedia.org/create-react-app
