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

相关推荐
lastHertz6 天前
openskill 实战指南:像管理 npm 包一样管理你的 AI Skill
前端·人工智能·npm
qq_589666057 天前
npm install npm install -g @vue/cli 分别是什么意思以及安装路径
前端·vue.js·npm
Dreamboat-L8 天前
NVM的安装与使用(保姆级教程)
npm·node.js
无责任此方_修行中9 天前
踩坑实录:为什么 `pnpm run` 会偷偷帮你装依赖?—— 浅析 pnpm 与 npm run 的底层差异
javascript·后端·npm
ShiXZ21311 天前
指令集-NPM 常用指令速查手册
前端·npm·node.js
是烨笙啊11 天前
从 npm 与 Bun 的选择看 AI 时代的“最佳实践”焦虑
前端·人工智能·npm
小杍随笔11 天前
【 .npmrc 终极配置指南:统一管理 npm/pnpm 缓存与全局目录,告别磁盘混乱】
前端·缓存·npm
ppshuX12 天前
npm-cli-造轮子初体验
npm
前端工作日常13 天前
我学习到的npx内部实现机制
npm
minglie114 天前
npm ali-oss库依赖冲突
前端·npm