使用Vite 创建 Vue3
安装项目
- 使用最新的vite 安装方式,vite官网。
npm create vite
-
填写项目名称、并选择创建项目类型
-
这里选择自定义模式,上面两个创建后好多插件需要自己引入。
-
选择自己需要插件,例如 TypeScript 语法
配置镜像
yarn
# 查看 yarn 当前镜像源
yarn config get registry
# 配置 yarn请求地址
yarn config set registry https://registry.yarnpkg.com
npm
# 1. 查看当前的npm镜像设置:
npm config list
# 2. 清空缓存:
npm cache clean --force
# 3. 设置镜像源
npm config set registry https://registry.npmmirror.com
## 常用的镜像源地址
# 淘宝镜像源 https://registry.npmmirror.com
# 腾讯云镜像源 http://mirrors.cloud.tencent.com/npm/
# 华为云镜像源 https://mirrors.huaweicloud.com/repository/npm/
# 官方默认全局镜像 https://registry.npmjs.org
# 4. 查看当前使用的镜像地址
npm config get registry
# 5. 创建项目
npm create vite