Skip to main content

更新到新版本

Create React App 分为两个包:

¥Create React App is divided into two packages:

  • create-react-app 是用于创建新项目的全局命令行实用程序。

    ¥create-react-app is a global command-line utility that you use to create new projects.

  • react-scripts 是生成的项目(包括这个项目)中的开发依赖。

    ¥react-scripts is a development dependency in the generated projects (including this one).

当你运行 npx create-react-app my-app 时,它会自动安装最新版本的 Create React App。

¥When you run npx create-react-app my-app it automatically installs the latest version of Create React App.

如果你之前已经通过 npm install -g create-react-app 全局安装了 create-react-app,请访问 新手入门 以了解当前的安装步骤。

¥If you've previously installed create-react-app globally via npm install -g create-react-app, please visit Getting Started to learn about current installation steps.

Create React App 使用最新版本的 react-scripts 创建项目,因此你将自动获得新创建的应用中的所有新功能和改进。

¥Create React App creates the project with the latest version of react-scripts so you’ll get all the new features and improvements in newly created apps automatically.

要将现有项目更新到 react-scripts 的新版本,打开变更日志,找到你当前使用的版本(如果你不确定,请检查此文件夹中的 package.json),然后应用更新版本的迁移说明。

¥To update an existing project to a new version of react-scripts, open the changelog, find the version you’re currently on (check package.json in this folder if you’re not sure), and apply the migration instructions for the newer versions.

在大多数情况下,将 react-scripts 版本升级到 package.json 并在此文件夹中运行 npm install(或 yarn install)应该就足够了,但最好咨询 变更日志 以了解潜在的重大更改。

¥In most cases bumping the react-scripts version in package.json and running npm install (or yarn install) in this folder should be enough, but it’s good to consult the changelog for potential breaking changes.

我们保证将重大更改保持在最低限度,以便你可以轻松升级 react-scripts

¥We commit to keeping the breaking changes minimal so you can upgrade react-scripts painlessly.