原创

React

如何搭建React+TypeScript脚手架项目

发表于 2022-03-26

更新于 3年前

阅读量: 1099

温馨提示

该文章距离上次更新已经过去了 1132 天,文章内容可能已经过时。

官方文档

create-react-app

下载

create-react-app 项目名称 --typescript
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1

提示

If you’ve previously installed create-react-app globally via npm install -g create-react-app, we recommend you uninstall the package using npm uninstall -g create-react-app or yarn global remove create-react-app to ensure that npx always uses the latest version.

Global installs of create-react-app are no longer supported.

官方文档中有提到如果之前全局下载过create-react-app,建议先删除之后再创建项目,保证使用的是最新的版本,且全局下载create-react-app已经不再支持

启动项目

切换到项目目录之后,使用yarn start启动项目

cd 项目目录
yarn start
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2

react+typescript

项目目录

react+typescript

评论
0/100
0/100
0/100
0/250
暂无评论