react+webpack搭建项目

时间:2023-03-10 02:42:28
react+webpack搭建项目

一、环境准备

①node

②npm

二、开始搭建

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

npm install -g create-react-app

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

create-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 (启动项目)