安装:
1. 安装node.js 配置golbal、cache等文件夹,参考常见的其他教程(cmd窗口用管理员模式运行,避免因为权限不足而报错)
2. 配置镜像
npm install -g cnpm –registry=http://registry.npmmirror.com
3. 安装yarn
npm install -g yarn
4. 安装vite
npm init vite@latest
窗口会返回以下信息,按需选择
Need to install the following packages:
create-vite@5.5.5
Ok to proceed? (y) y
> npx
> create-vite
√ Project name: ... client
√ Select a framework: » Vue
√ Select a variant: » TypeScript
Scaffolding project in D:\hzj_program\nodejs\program\client...
Done. Now run:
cd client
npm install
npm run dev
added 47 packages in 13s
6 packages are looking for funding
run `npm fund` for details
5. 按他的信息,依次运行三条命令
cd client
npm install让项目下载对应的依赖,如果运行很久没反应,就说明镜像不行,上网换一个
npm install
npm run dev 运行项目
npm run dev
6. 出现以下信息,说明创建项目成功
> client@0.0.0 dev
VITE v5.4.11 ready in 509 ms
➜ Local: http://localhost:5173/
➜ Network: use --host to expose
➜ press h + enter to show help
去浏览器输入localhost:5173即可
tips:
可安装nrm源管理工具
npm i nrm -g
使用 nrm ls 即可查看源列表信息