第一步:安装node.js
第二步:设置npm的国内镜像,使用淘宝镜像 https://npmmirror.com/
// 方式一:
// 设置仓库镜像地址:
npm config set registry https://registry.npmmirror.com
// 查看配置是否生效:
npm config get registry
// 方式二:
npm install -g cnpm --registry=https://registry.npmmirror.com
第三步: 安装reactJs的手脚架工具包
npm install -g create-react-app
ps:没有安装手脚架工具包会出现错误:
'create-react-app' 不是内部或外部命令,也不是可运行的程序 或批处理文件。
第四步: 官网文档 https://reactjs.org/docs/create-a-new-react-app.html
npx create-react-app my-app
cd my-app
npm start
使用TypeScript模板
npx create-react-app my-app-ts --template typescript
使用yarn包管理工具
tyarn只是使用了淘宝的镜像
npm install yarn tyarn -g
tyarn create react-app my-app-ts --template typescript