Ubuntu 22.04下Yarn设置proxy配置报错及install问题求助
解决Yarn代理配置报错及包拉取问题
先确认你的Yarn版本:
执行yarn --version,Yarn v2+(Berry版本)不再使用proxy这个配置项,改用httpProxy和httpsProxy,这是你报错的核心原因。针对Yarn Berry(v2+)配置代理:
执行以下命令替换成你的代理地址:yarn config set httpProxy http://my.proxy.url:port yarn config set httpsProxy http://my.proxy.url:port如果代理需要账号密码认证,格式改为
http://username:password@my.proxy.url:port如果你用的是Yarn Classic(v1.x版本):
注意配置项名称,https代理是带横杠的https-proxy,并且要加上协议前缀:yarn config set proxy http://my.proxy.url:port yarn config set https-proxy http://my.proxy.url:port验证配置是否生效:
执行yarn config list,检查输出里是否有你设置的代理项。解决包拉取问题:
清理Yarn缓存后重新安装:yarn cache clean yarn install
内容的提问来源于stack exchange,提问作者biagio8
相关产品推荐
相关产品推荐

