Create React App
- 通过npx安装(新的方式,未来推荐)。
npx on the first line is not a typo — it’s a package runner tool that comes with npm 5.2+.
npm v5.2.0引入的一条命令(npx),引入这个命令的目的是为了提升开发者使用包内提供的命令行工具的体验。
npx create-react-app my-react-app这条命令会临时安装 create-react-app 包,命令完成后create-react-app 会删掉,不会出现在 global 中。下次再执行,还是会重新临时安装。
npx create-react-app my-react-app
- 通过cnpm安装(目前推荐)。
国内下载太慢,也可以使用淘宝定制的 cnpm 进行安装。
cnpm install -g create-react-app
create-react-app my-app
安装完成后,进入my-app目录,使用 npm start 命令启动。
启动界面: