react+webpack搭建项目

一、环境准备

①node

②npm

二、开始搭建

①使用npm安装create-react-app工具,在cmd命令行中输入:

npm install -g create-react-app

②使用命令创建新的react项目,在cmd命令行中输入:

create-react-app first-react-app

// first-react-app为你需要创建的项目名称

③打开创建好的项目文件夹(此例中为first-react-app的文件夹),接着在cmd命令行中输入:

npm init  (然后一直回车)

npm install --save react react-dom (在该目录下导入react和react-dom)

npm install --save react-router-dom (react路由)

npm start (启动项目)

原文地址:https://www.cnblogs.com/yuanxinru321/p/10494605.html