简体   繁体   English

如何将使用 create-react-app 构建的 React 项目升级到下一个 create-react-app 版本?

[英]How to upgrade a React project built with create-react-app to the next create-react-app version?

I have a React project built with create-react-app 1.5.我有一个用create-react-app 1.5 构建的 React 项目。 I would like to get the features of create-react-app 2.0 for my React project.我想为我的 React 项目获得create-react-app 2.0 的功能。

Specifically I would like to use this: https://github.com/facebook/create-react-app/pull/3909具体我想用这个: https : //github.com/facebook/create-react-app/pull/3909

Basically, to upgrade a create-react-app project, all you need to do is update the react-scripts module to the latest version and update your app to be compatible with any breaking changes in react-scripts .基本上,要升级create-react-app项目, 您需要做的就是将react-scripts模块更新到最新版本,并更新您的应用程序以与react-scripts任何重大更改兼容。

Run yarn upgrade --latest react-scripts , rebuild your app, and everything should more-or-less work, barring any breaking changes.运行yarn upgrade --latest react-scripts ,重建你的应用程序,一切都应该或多或少地工作,除非有任何yarn upgrade --latest react-scripts变化。

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. create-react-app是一个全局命令行实用程序,可用于创建新项目。 react-scripts is a development dependency in the generated projects (including this one). react-scripts是生成的项目(包括这个)中的一个开发依赖项。 When you run npx create-react-app my-app it automatically installs the latest version of Create React App.当您运行npx create-react-app my-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.如果您之前已通过npm install -g create-react-app全局安装 create-react-app ,请访问入门以了解当前的安装步骤。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM