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 天前
轻量无依赖!autoviwe 页面自适应组件实战:从安装到源码深度解析
javascript·arcgis·npm·css3·html5
aidou13142 天前
Visual Studio Code(VS Code)安装步骤
vscode·npm·node.js·环境变量
全栈小52 天前
【前端】win11操作系统安装完最新版本的NodeJs运行npm install报错,提示在此系统上禁止运行脚本
前端·npm·node.js
DevOps探索之旅3 天前
Hadess从入门到精通,如何详细管理Npm制品
npm·hadess·国产开源制品管理工具·一文上手
一心赚狗粮的宇叔4 天前
VScode常用扩展包&Node.js安装及npm包安装
vscode·npm·node.js·web
嘿是我呀4 天前
【用npm安装node时报错“npm 无法加载文件”】
前端·npm·node.js
Hexene...4 天前
【前端Vue】npm install时根据新的状态重新引入实际用到的包,不引入未使用到的
前端·vue.js·npm
霸气小男4 天前
使用nvm安装node之后在vscode中无法使用npm报错
npm
i建模5 天前
在 Ubuntu 中为 npm 切换国内镜像源
linux·ubuntu·npm
每天瞎忙的农民工5 天前
Ubuntu 24 安装npm22
linux·运维·ubuntu·npm