react前端如何启动
启动React前端项目的步骤
确保已安装Node.js(建议版本≥12.x),可通过以下命令检查版本:
node -v
npm -v
全局安装create-react-app脚手架工具(如未安装):
npm install -g create-react-app
创建新React项目:
npx create-react-app my-app
进入项目目录并启动开发服务器:

cd my-app
npm start
项目默认会在浏览器打开 http://localhost:3000,修改代码会自动热更新。
其他常用命令
生产环境构建:

npm run build
运行测试:
npm test
弹出webpack配置(不可逆操作):
npm run eject
快速启动替代方案
使用Vite创建React项目(更快的启动速度):
npm create vite@latest my-app --template react
cd my-app
npm install
npm run dev





