network request to https://registry.npmjs.org/xxx failed, reason: connect ETIM

目录:

1、问题描述

npm install 时,报错:npm ERR! network request to https://registry.npmjs.org/postcss-pxtorem failed, reason: connect ETIMEDOU

powershell 复制代码
npm ERR! code ETIMEDOUT
npm ERR! errno ETIMEDOUT
npm ERR! network request to https://registry.npmjs.org/postcss-pxtorem failed, reason: connect ETIMEDOUT 104.16.1.35:443
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'

2、解决方案

powershell 复制代码
//1.查看npm镜像设置
npm config get registry

//2.将npm设置为淘宝镜像
npm config set registry npm config set registry https://registry.npmmirror.com

//3.再次查看npm镜像设置
npm config get registry

3、npm镜像仓库替换

powershell 复制代码
//替换镜像的操作
1、查看当前的npm镜像设置:npm config list
2、清空缓存:npm cache clean --force
3、替换镜像地址:npm config set registry https://registry.npmmirror.com

!!!注意:此处修改的镜像用的是npm本身,一般国内用户还是建议使用淘宝镜像,所以推荐还是设置成用淘宝镜像,执行:npm config set registry https://registry.npmmirror.com 【推荐】

相关推荐
网络点点滴7 小时前
NPM 和 package.json 文件简介
前端·npm·json
青木9607 小时前
前后端开发调试运行技巧
linux·服务器·前端·后端·npm·uv
Rabbit_QL7 小时前
npm 不是“前端的包管理器“—它是 Node.js 的
前端·npm·node.js
草履虫君7 小时前
原电脑只运行了:npm install -g openclaw 要把它迁移到一个新电脑,怎么操作,菜鸟教程
经验分享·ai·npm
是大强8 小时前
nvm安装node成功npm失败
前端·npm·node.js
weixin_427771611 天前
overscroll-behavior 防止滑动穿透
npm
Rabbit_QL1 天前
【前端基础】npm install 是干嘛的(带参数 vs 不带参数)
前端·npm·node.js
Rabbit_QL1 天前
【前端工具链小白篇】前端工具链全景:Node、npm、Vite 各管什么
前端·npm·node.js
福大大架构师每日一题3 天前
openclaw v2026.4.21 更新:图像生成、权限安全、插件修复、Slack 线程、浏览器与 npm 安装全面优化
前端·安全·npm
天若有情6734 天前
【开源推荐】form-validator-cn 轻量级中文表单校验库 | TS 零依赖、极简开箱即用
前端·npm·开源·node·js·表单校验