一、yarn 1.x
1. 全局安装
npm i yarn -g
手动设置淘宝源 yarn1.x npm
yarn config set registry https://registry.npmmirror.com
2. 配置文件
二、yarn2.x & yarn3.x
1. 使用corepack安装
node版本大于v16.13
1.1 开启corepack 功能
1.2开启高版本pnpm
corepack prepare yarn@3.1.1 --activate
2. yarn命令
2.1 查看配置
-
2.2 修改npm源
yarn config set npmRegistryServer https://registry.npmmirror.com
只能设置在本地,暂时不能全局设置3. 工程跑不起来的解决方案
```bash
.yarnrc.yml
npmRegistryServer: “https://registry.npmmirror.com“
如果工程跑不起来可以先尝试增加下面的配置:
nodeLinker: “pnp” pnpMode: “loose”
如果仍然跑不起来,可以用下面的配置完全按照以前的依赖按照方式
nodeLinker: “node-modules”
<a name="ZTG4z"></a>
### 4. .gitignore配置
If you're using Zero-Installs:
```bash
.yarn/*
!.yarn/cache
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
If you’re not using Zero-Installs:
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions