跳转至

前端开发环境配置

安装 Node

https://nodejs.org/zh-cn/ 下载 Node LTS

2021.12.6: Node 最新 LTS 版本 16.13.1

安装 Yarn

根据 https://yarnpkg.com/getting-started/install

corepack enable
yarn set version stable
yarn --version # 3.1.1

使用 Yarn 全局安装的命令行文件, windows 下在 %LocalAppData%\Yarn\bin, 可以添加为环境变量

npm install -g create-vite-app

镜像

手动设置镜像

npm config set registry https://registry.npmmirror.com/
npm config set disturl https://npm.taobao.org/dist
npm config set electron_mirror https://npm.taobao.org/mirrors/electron/
npm config set ELECTRON_BUILDER_BINARIES_MIRROR http://npm.taobao.org/mirrors/electron-builder-binaries/
npm config set SASS_BINARY_SITE https://npm.taobao.org/mirrors/node-sass/
# Yarn 1
yarn config set registry https://registry.npmmirror.com/
yarn config set disturl https://npm.taobao.org/dist
yarn config set electron_mirror https://npm.taobao.org/mirrors/electron/
yarn config set ELECTRON_BUILDER_BINARIES_MIRROR http://npm.taobao.org/mirrors/electron-builder-binaries/
yarn config set SASS_BINARY_SITE https://npm.taobao.org/mirrors/node-sass/
# Yarn 3
yarn config set npmRegistryServer https://registry.npmmirror.com/

使用 mirror-config-china 自动设置镜像

npm i -g mirror-config-china --registry=https://registry.npmmirror.com
# 检查是否安装成功
npm config list

常用工具

yarn global add create-vite-app
yarn global add typescript

Vue

yarn create @vitejs/app vue-test
cd vue-test
yarn
yarn dev

常用指令

yarn # 安装依赖
yarn --registry=https://registry.npmjs.org # 指定源
yarn global add # 全局安装
yarn add --dev # 局部安装为 devDependencies