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

相关推荐
ChinaLzw31 分钟前
配置npm国内源(包含主流npm镜像源地址)
npm·node.js
辉长六加14 小时前
nodejs和vue安装步骤记录
前端·javascript·vue.js·npm·node.js
SuperYing2 天前
还在为调试组件库发愁吗?yalc 帮你一把
前端·npm
棒棒的唐2 天前
nodejs安装后 使用npm 只能在cmd 里使用 ,但是不能在poowershell使用,只能用npm.cmd
前端·npm·node.js
字节逆旅3 天前
nvm 安装pnpm的异常解决
前端·npm
DevSecOps选型指南3 天前
SBOM风险预警 | NPM前端框架 javaxscript 遭受投毒窃取浏览器cookie
前端·人工智能·前端框架·npm·软件供应链安全厂商·软件供应链安全工具
lovepenny4 天前
Failed to resolve entry for package "js-demo-tools". The package may have ......
前端·npm
stoneSkySpace4 天前
pnpm 和 npm 差异
前端·npm·node.js
海上彼尚6 天前
使用 npm-run-all2 简化你的 npm 脚本工作流
前端·npm·node.js
HWL56796 天前
pnpm(Performant npm)的安装
前端·vue.js·npm·node.js