问题
今天jenkins打包一个项目,发现报错了
error An unexpected error occurred: "https://registry.nlark.com/xxxxxxxxxx.tgz: getaddrinfo ENOTFOUND registry.nlark.com".

先写解决方案
把yarn.lock文件里面的registry.nlark.com替换为registry.npmmirror.com
解决过程
本地打包是没有问题的,一开始觉得是jenkins配置的问题,但是项目组内的大佬说这种镜像源问题先看前端自己能不能解决
直接访问https://registry.nlark.com/是访问不到的

开始查找registry.nlark.com的内容,先看到这个帖子:
registry.nlark.com 域名异常问题 - 掘金
发现是淘宝处理镜像源的一个临时解决方案,那随时可能被放弃

这帖楼主解决方法是这样的:删除yarn.lock和nodemodule并重新yarn install

但是我本地打包失败了,出现了node版本不匹配问题,其实可以升级node版本解决,但是由于是公司项目,最好还是不要动node版本,于是我继续查找解决方法
发现了这个帖子:
如何解决:error An unexpected error occurred: "https://registry.nlark.com-CSDN博客
想起之前淘宝源彻底不能使用的问题,所以我进行了尝试,把yarn.lock文件里面的registry.nlark.com替换为registry.npmmirror.com
更改后重新上传打包,发现成功打包了,问题成功解决

反思
回想了一下为啥本地可以打包,原来是因为本地设置了代理:
