无法安装任何npm包,已尝试清除代理配置及.npmrc仍报错
npm 网络超时(ETIMEDOUT)问题解决建议
已执行npm config delete http-proxy并删除.npmrc文件,但仍出现以下网络超时错误:
npm ERR! code ETIMEDOUT npm ERR! syscall connect npm ERR! errno ETIMEDOUT npm ERR! network request to http://registry.npmjs.org/express failed, reason: connect ETIMEDOUT 2606:4700:90c3:80e2:e464:3f2:6810:22:80 npm ERR! network This is a problem related to network connectivity. npm ERR! network In most cases you are behind a proxy or have bad network settings. npm ERR! network npm ERR! network If you are behind a proxy, please make sure that the npm ERR! network 'proxy' config is set properly. See: 'npm help config'
排查及解决步骤:
- 检查系统全局代理设置:系统级代理(如Windows Internet选项、macOS网络设置)可能覆盖npm配置,尝试关闭全局代理,或将
registry.npmjs.org加入代理白名单。 - 切换国内npm镜像:执行
npm config set registry https://registry.npmmirror.com,通过国内镜像规避国际网络链路问题。 - 检查防火墙/杀毒软件:临时关闭本地防火墙或杀毒软件,确认是否是它们拦截了npm的网络请求,必要时给npm添加访问权限。
- 彻底清除npm代理配置:执行以下命令确保所有代理配置被清除:
执行npm config delete proxy npm config delete https-proxynpm config list确认输出中无proxy或https-proxy相关配置。 - 测试网络连通性:用
ping registry.npmjs.org或curl http://registry.npmjs.org/express测试本地网络是否能正常访问npm仓库,排查基础网络问题。
内容的提问来源于stack exchange,提问作者Karan Pandey
相关产品推荐
相关产品推荐

