解决npm问题:错误的代理设置

错误的代理设置

复制代码
npm install vue-waterfall-plugin-next
npm ERR! code ECONNREFUSED
npm ERR! syscall connect
npm ERR! errno ECONNREFUSED
npm ERR! FetchError: request to https://registry.npmmirror.com/vue-waterfall-plugin-next failed, reason: connect ECONNREFUSED 127.0.0.1:31181
npm ERR!     at ClientRequest.<anonymous> (F:\Tools\nodejs\node_modules\npm\node_modules\minipass-fetch\lib\index.js:130:14)
npm ERR!     at ClientRequest.emit (node:events:517:28)
npm ERR!     at onerror (F:\Tools\nodejs\node_modules\npm\node_modules\agent-base\dist\src\index.js:117:21)
npm ERR!     at callbackError (F:\Tools\nodejs\node_modules\npm\node_modules\agent-base\dist\src\index.js:136:17)
npm ERR!     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
npm ERR!  FetchError: request to https://registry.npmmirror.com/vue-waterfall-plugin-next failed, reason: connect ECONNREFUSED 127.0.0.1:31181
npm ERR!     at ClientRequest.<anonymous> (F:\Tools\nodejs\node_modules\npm\node_modules\minipass-fetch\lib\index.js:130:14)
npm ERR!     at ClientRequest.emit (node:events:517:28)
npm ERR!     at onerror (F:\Tools\nodejs\node_modules\npm\node_modules\agent-base\dist\src\index.js:117:21)
npm ERR!     at callbackError (F:\Tools\nodejs\node_modules\npm\node_modules\agent-base\dist\src\index.js:136:17)
npm ERR!     at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
npm ERR!   code: 'ECONNREFUSED',
npm ERR!   errno: 'ECONNREFUSED',
npm ERR!   syscall: 'connect',
npm ERR!   address: '127.0.0.1',
npm ERR!   port: 31181,
npm ERR!   type: 'system',
npm ERR!     at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
npm ERR!   code: 'ECONNREFUSED',
npm ERR!   errno: 'ECONNREFUSED',
npm ERR!   syscall: 'connect',
npm ERR!   address: '127.0.0.1',
npm ERR!   port: 31181,
npm ERR!   type: 'system',
npm ERR!   code: 'ECONNREFUSED',
npm ERR!   errno: 'ECONNREFUSED',
npm ERR!   syscall: 'connect',
npm ERR!   address: '127.0.0.1',
npm ERR!   port: 31181,
npm ERR!   type: 'system',
npm ERR!   syscall: 'connect',
npm ERR!   address: '127.0.0.1',
npm ERR!   port: 31181,
npm ERR!   type: 'system',
npm ERR!   type: 'system',
npm ERR!   requiredBy: '.'
npm ERR! }
npm ERR!
npm ERR! If you are behind a proxy, please make sure that the
npm ERR! 'proxy' config is set properly.  See: 'npm help config'

npm ERR! A complete log of this run can be found in: F:\Tools\nodejs\node_cache\_logs\2025-02-20T01_02_46_768Z-debug-0.log

遇到此问题是因为 npm 配置了错误的代理设置,导致尝试通过本地未被监听的端口(127.0.0.1:31181)进行连接。以下是分步解决方案:

步骤 1:清除 npm 的代理配置

在命令行中执行以下命令,移除可能存在的代理设置:

bash 复制代码
npm config delete proxy
npm config delete https-proxy

步骤 2:检查环境变量中的代理设置

确保没有设置 HTTP_PROXYHTTPS_PROXY 环境变量。在 Windows 的 CMD 中运行:

cmd 复制代码
set HTTP_PROXY
set HTTPS_PROXY

如果发现这些变量被设置,需要取消设置。在 CMD 中:

cmd 复制代码
set HTTP_PROXY=
set HTTPS_PROXY=

在环境变量中将 HTTP_PROXY和 HTTPS_PROXY 删除

重新npm install xxx 即可成功。

相关推荐
爱健身的小刘同学14 小时前
Vue 3 + Leaflet 地图可视化
前端·javascript·vue.js
神秘的猪头14 小时前
Ajax 数据请求:从零开始掌握异步通信
前端·javascript
稀饭5214 小时前
用changeset来管理你的npm包版本
前端·npm
TeamDev14 小时前
基于 Angular UI 的 C# 桌面应用
前端·后端·angular.js
就知道你是成心的15 小时前
npm pack 一键构建npm离线包
npm
Komorebi゛15 小时前
【CSS】斜角流光样式
前端·css
Irene199115 小时前
CSS 废弃属性分类总结
前端·css
青莲84315 小时前
Android 事件分发机制 - 事件流向详解
android·前端·面试
musashi15 小时前
用 Electron 写了一个 macOS 版本的 wallpaper(附源码、下载地址)
前端·vue.js·electron
满天星辰15 小时前
Typescript之类型总结大全
前端·typescript