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

相关推荐
AlfredZhao2 天前
npm 源切换:一条命令搞定
npm
@tangguo1233 天前
npm 和 yarn 配置说明
前端·javascript·npm·node.js·yarn
钝挫力PROGRAMER7 天前
npx 与 npm 全局安装/更新/卸载
npm·npx·mcp·dsh
天若有情6739 天前
开源轻量双语工具|一键批量查询 NPM 包历史下载量,支持按作者批量统计
javascript·npm·github pages·开源工具·netlify·前端开源·npm克隆量
柚稚姐姐13 天前
npm install pnpm -g npm error code EACCES npm error syscall symlink
前端·npm·node.js
晴天1614 天前
npm install -f(--force)深度解析:作用原理、报错根源与风险避坑指南
前端·npm·node.js
晴天1614 天前
.npmrc 配置文件全解析:从换源到工程化的完整指南
npm·npmrc
晴天1615 天前
peerDependencies 全面解析:前端依赖生态的核心机制与实战指南
前端·npm
晴天1618 天前
打造自己的 npm 包实战指南
前端·npm·node.js
西西小飞龙18 天前
npm vs pnpm
前端·npm·node.js