mkdir react-v18.2
cd react-v18.2
pnpm init -y
新建.npmrc
文件指定npm
为taobao
源
registry=https://registry.npmmirror.com
安装vite和react的vite插件
npm install vite @vitejs/plugin-react --save-dev
新建html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite App</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.jsx"></script>
</body>
</html>
{
"scripts": {
"dev": "vite"
}
}
启动命令
npm run dev