安装教程:
配置镜像地址:
npm config set registry https://registry.npmmirror.com
//镜像:https://developer.aliyun.com/mirror/NPM
安装yarn:
npm install --global yarn
查看版本:
yarn --version
卸载:
npm uninstall -g yarn
安装固定版本yarn:
npm install -g yarn@1.22.17
错误1:error Error: certificate has expired
解决方案:
输入:yarn config list
如果是true,输入:yarn config set strict-ssl false
解决问题。
错误2:info There appears to be trouble with your network connection. Retrying…
解决方案:
方法1:
更换淘宝镜像:
yarn config set registry https://registry.npmmirror.com
移除原代理:
yarn config delete proxy
npm config rm proxy
npm config rm https-proxy
方法2:
直接删除项目根目录的yarn.lock文件,再设置yarn国内镜像:
yarn config set registry https://registry.npmmirror.com
再安装 yarn:
yarn install
方法3.
将 yarn.lock 中的 https://registry.yarnpkg.com 换成 https://registry.npmmirror.com
如果遇到其他问题,然后试了各种方法未解决,比如一直报超时
info There appears to be trouble with your network connection. Retrying…
最后若还是解决不了:
请打开C:\Windows\System32\cmd.exe右键管理员模式运行,执行yarn install。