ERR_PNPM_META_FETCH_FAIL  GET https://xxx,request to failed, reason: Socket time

1,187 阅读1分钟

背景npm 或pnpm 下载依赖特别慢,并且出现了一些报错信息。之前使用pnpm install xx下载资源很快,可能是最近对npm, pnpm做了升级导致。 这个升级信息还真不能随便升级。

  • 环境信息
pnpm --version
8.6.2

npm --version
9.8.1

node --version
v16.14.2
  • 首先想到就是更换npm镜像源
npm config set registry https://registry.npm.taobao.org
# 验证命令是否生效
npm config get registry
# 如果返回https://registry.npm.taobao.org,说明镜像配置成功。


//镜像仓库(淘宝,华为,官方,腾讯)
npm config set registry https://registry.npm.taobao.org
npm config set registry https://registry.npmjs.org
npm config set registry https://mirrors.huaweicloud.com/repository/npm/
npm config set registry http://mirrors.cloud.tencent.com/npm/


npm install -g cnpm --registry=https://registry.npm.taobao.org


//查看npm配置
npm config list

  • 执行pnpm install xxx 出现如下报错
 ERR_PNPM_REGISTRIES_MISMATCH  This modules directory was created using the following 
 registries configuration: {"default":"https://registry.npmjs.org/"}. 
 The current configuration is {"default":"https://registry.npm.taobao.org/"}. 
 To recreate the modules directory using the new settings, run "pnpm install".

上述的意思就是这个模块使用默认的镜像地址, 不支持淘宝镜像源。我们可以通过。

npm config set registry https://registry.npmjs.org
# 更换镜像源头

更换镜像源后,再次执行pnpm install xx ,出现如下报错。

https://registry.npmjs.org/errno error (ERR_SOCKET_TIMEOUT). Will retry in 10 seconds. 2 retries left.

GET https://registry.npmjs.org/strip-ansi: request to
https://registry.npmjs.org/strip-ansi failed, reason: Socket timeout

经过一些列排查, 可能是升级pnpm 导致install下载变慢了。
The problem now seems to appear only on pnpm 8.3.x

vim /etc/nginx
104.16.26.34 registry.npmjs.org