Create React App是一种官方支持的创建单页React应用程序的方法。它提供了一个没有配置的现代构建设置。
一、全局安装脚手架:
npm install -g create-react-app
二、创建react应用
- 使用npx创建应用可跳过上面的第一步
npx create-react-app my-app
- 使用npm一键创建可跳过上面的第一步
npm init react-app my-app
注意:npm的版本须在6+以上
- 使用yarn一键创建可跳过上面的第一步
yarn create react-app my-app
- 使用全局脚手架创建
create-react-app my-app
三、生成的目录结构
my-app
├── README.md
├── node_modules
├── package.json
├── .gitignore
├── public
│ ├── favicon.ico
│ ├── index.html
│ └── manifest.json
└── src
├── App.css
├── App.js
├── App.test.js
├── index.css
├── index.js
├── logo.svg
└── serviceWorker.js
四、运行
npm start