全局安装:npm  install -g yarn

检查是否安装成功 yarn -v

切换淘宝镜像:yarn config set registry https://registry.npm.taobao.org

如果提示

yarn : 无法加载文件 C:\Users\XXXX\AppData\Roaming\npm\yarn.ps1,因为在此系统上禁止运行脚本。有关详细信息,请参阅 https
:/go.microsoft.com/fwlink/?LinkID=135170 中的 about_Execution_Policies。
所在位置 行:1 字符: 1
+ yarn
+ ~~~~
    + CategoryInfo          : SecurityError: (:) [],PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess

因为系统上禁止运行脚本

解决方法:
1、管理员身份运行power shell
2、输入set-ExecutionPolicy RemoteSigned并按下确认
3、get-ExecutionPolicy(查看是否成功,可省略)