You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

更换D-Link AX3200路由器后npm/yarn安装超时,需配置hosts的问题咨询

大家好,我最近换路由器后碰到个头疼的问题,想问问有没有朋友遇到过类似情况:

之前用华硕RT-AC86U路由器时,跑yarn add或者npm install完全正常,根本不需要修改/etc/hosts文件。但刚换了D-Link EXO AX AX3200路由器(没改任何默认设置),npm和yarn直接没法用了,一直报网络连接失败、超时错误,具体日志如下:

verbose 0.284464907 Performing "GET" request to "https://yarnpkg.com/latest-version".

[1/4] Resolving packages...

verbose 0.354563031 Performing "GET" request to "https://registry.yarnpkg.com/@apollo%2fclient".

info There appears to be trouble with your network connection. Retrying...

但奇怪的是,我用浏览器能正常访问https://registry.yarnpkg.com/@apollo%2fclient,用curl直接下载包也没问题,比如执行这条命令:

curl -o test.tgz -v https://registry.yarnpkg.com/vue-axios/-/vue-axios-2.1.4.tgz

所以我猜测问题应该出在npm/yarn配置和新路由器的兼容上?

目前我找到的临时解决办法是在/etc/hosts里添加两条IP映射:

104.16.93.83   registry.npmjs.org
104.16.26.35   yarn.npmjs.org

加完之后npm和yarn就能正常工作了,但旧路由器根本不需要这么做,所以我对这个D-Link路由器的体验真的挺差的。

想问问大家有没有换路由器后遇到npm/yarn这类包管理工具网络异常的情况?

另外附上我的yarn和npm配置信息,供大家参考:

Yarn 配置

yarn config v1.22.19

info yarn config

{
  'version-tag-prefix': 'v',
  'version-git-tag': true,
  'version-commit-hooks': true,
  'version-git-sign': false,
  'version-git-message': 'v%s',
  'init-version': '1.0.0',
  'init-license': 'MIT',
  'save-prefix': '^',
  'bin-links': true,
  'ignore-scripts': false,
  'ignore-optional': false,
  registry: 'https://registry.yarnpkg.com',
  'strict-ssl': true,
  'user-agent': 'yarn/1.22.19 npm/? node/v19.9.0 linux x64'
}

NPM 配置

info npm config

{
  prefix: '/home/me/.node_modules'
}

更新补充信息

我的ISP不允许启用IPv6,用相关工具测试的traceroute结果如下:

$ traceroute to yarn.npmjs.org (2606:4700::6810:1423), 30 hops max, 80 byte packets
# 1  R32-CEEE.local (ROUTER_IP_V6_ADDRESS)  0.636 ms  0.595 ms  0.588 ms
2  * * *

备注:内容来源于stack exchange,提问作者RedGiant

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.22 15:18:19