二.创建项目

1.创建普通 react 项目

通过 create-react-app 脚手架快速搭建 react 项目

要求:Node>=8.10 并且 npm>=5.6

安装 create-react-app

npm install -g create-react-app

检测 create-react-app 是否安装成功

create-react-app -V # 注意:V 是大写的

创建 react 项目

  • 通过脚手架创建一个 React 项目
npx create-react-app my-app # 注意:名字不能包含大写字母
# 或者
# create-react-app my-app
cd my-app
npm start

说明:npx 是 npm 5.2+ 附带的 package 运行工具

2.创建 react+ typescript 项目

npx create-react-app my-app --template typescript