create-react-app脚手架搭建react项目
Quick Start(快速入门)
全局安装
首先确保你电脑上安装最新的版本
#全局安装
npm install -g create-react-app
#构建一个my-app的项目
npx create-react-app my-app
cd my-app
启动编译当前的React项目,并自动打开 http://localhost:3000/
npm start
以上命令执行完成后,则自动打开: http://localhost:3000/
如果你不能确保最新版本,可以先尝试卸载: npm uninstall -g create-react-app,然后再全局安装。
构建React项目的其他方式
npm
npm init <initializer> is available in npm 6+
npm init react-app my-app
Yarn
yarn create is available in Yarn 0.25+
yarn create react-app my-app
配合TypeScript
第一种方式:创建项目的时候直接配置好TypeScript.
npx create-react