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

相关推荐
一枚前端小能手10 小时前
📦 从npm到yarn到pnpm的演进之路 - 包管理器实现原理深度解析
前端·javascript·npm
scorpion_V2 天前
VScode 中执行 npm 报错的问题
ide·vscode·npm
FreeBuf_2 天前
攻击者利用Discord Webhook通过npm、PyPI和Ruby软件包构建隐蔽C2通道
前端·npm·ruby
程序铺子3 天前
如何使用 npm 安装 sqlite3 和 canvas 这些包
javascript·npm·node.js
gc_22994 天前
Ape.Volo项目启动前端项目时报错“digital envelope routines::unsupported”
npm
SHUIPING_YANG4 天前
完美迁移:将 nvm 和 npm 完全安装到 Windows D 盘
前端·windows·npm
问道飞鱼5 天前
【前端知识】npm依赖升级以及冲突解决
前端·arcgis·npm·升级·冲突解决
美酒没故事°5 天前
npm源管理器:nrm
前端·npm·npm源
三十_A5 天前
【实录】使用 patch-package 修复第三方 npm 包中的 Bug
前端·npm·bug
孟陬6 天前
一个专业的前端如何在国内安装 `bun`
npm·github·bun