react 如何启动
创建 React 项目
使用官方工具 create-react-app 快速初始化项目,需提前安装 Node.js(版本 ≥ 14.0.0)和 npm/yarn:
npx create-react-app my-app
或通过 Yarn:
yarn create react-app my-app
启动开发服务器
进入项目目录后运行以下命令启动开发环境:

cd my-app
npm start
或使用 Yarn:
yarn start
默认在浏览器打开 http://localhost:3000,代码修改会实时热更新。

构建生产版本
生成优化后的静态文件,输出至 build 文件夹:
npm run build
或:
yarn build
其他常用命令
- 测试运行:
npm test或yarn test - 暴露配置(慎用):
npm run eject或yarn eject






