react --- 搭建环境

搭建react开发环境的准备工作

1. node.js 稳定版本

2. 安装cnpm,用cnpm代替npm

3. 用yarn替代npm

yarn的安装:npm install -g yarn

搭建react开发环境的第一种方法(老-现在推荐)

1. 安装脚手架工具  只需要安装一次

  npm install -g create-react-app /  cnpm install -g create-react-app

2. 创建项目

  找到项目要创建的目录: 

  create-react-app reactname

3. cd到项目里面

  npm start / yarn start 运行项目

  npm run build / yarn build 生成项目

 

搭建react开发环境的第二种方法(新-未来推荐) 

1. 找到项目要创建的目录执行 

  npx create-react-app reactdemo

  包括的步骤:

    a. 安装 npm install -g create-react-app

    b. 创建 create-react-app reactname

    c. 删除

npx介绍

npm v5.2.0引入的一条命令(npx),引入这个命令的目的是为了提升开发者使用包内提供的命令行工具的体验。

猜你喜欢

转载自www.cnblogs.com/liuyunqi/p/10636147.html
今日推荐