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 【推荐】

相关推荐
半开半落1 小时前
uniapp通过npm使用第三方库兼容微信小程序
微信小程序·npm·uni-app
jenchoi4133 小时前
【2025-11-15】软件供应链安全日报:最新漏洞预警与投毒预警情报汇总
前端·网络·安全·网络安全·npm·node.js
P***25392 天前
前端构建工具缓存清理,npm cache与yarn cache
前端·缓存·npm
好奇的菜鸟2 天前
解决 npm 依赖版本冲突:从 “unable to resolve dependency tree“ 到依赖管理高手
前端·npm·node.js
猿小猴子2 天前
Node 的版本管理工具 nvm 介绍
npm·node·nvm
jenchoi4133 天前
【2025-11-12】软件供应链安全日报:最新漏洞预警与投毒预警情报汇总
网络·安全·web安全·网络安全·npm
jenchoi4133 天前
【2025-11-13】软件供应链安全日报:最新漏洞预警与投毒预警情报汇总
网络·安全·web安全·网络安全·npm
百***78453 天前
node.js+npm的环境配置以及添加镜像(保姆级教程)
arcgis·npm·node.js
菠萝+冰3 天前
npm中-d -g 和默认安装的区别
前端·npm·node.js
jenchoi4134 天前
【2025-11-11】软件供应链安全日报:最新漏洞预警与投毒预警情报汇总
网络·安全·web安全·网络安全·npm