记录使用 npm element-plus --save 安装element(vue3 ) 出现 ERR! code ECONNREFUSED
作者:陈三顺子 日期:2022-06-20 11:26:20 点击:5349
场景:
使用 npm element-plus --save
问题:
npm ERR! code ECONNREFUSED
npm ERR! errno ECONNREFUSED
npm ERR! FetchError: request to https://registry.npmjs.org/element-plus failed, reason: connect ECONNREFUSED 127.0.0.1:443
npm ERR! at ClientRequest.<anonymous> (D:\Nodejs\node_modules\npm\node_modules\node-fetch-npm\src\index.js:68:14)
npm ERR! at ClientRequest.emit (events.js:210:5)
npm ERR! at TLSSocket.socketErrorListener (_http_client.js:406:9)
npm ERR! at TLSSocket.emit (events.js:210:5)
npm ERR! at emitErrorNT (internal/streams/destroy.js:92:8)
npm ERR! at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
npm ERR! at processTicksAndRejections (internal/process/task_queues.js:80:21)
npm ERR! FetchError: request to https://registry.npmjs.org/element-plus failed, reason: connect ECONNREFUSED 127.0.0.1:443
npm ERR! at ClientRequest.<anonymous> (D:\Nodejs\node_modules\npm\node_modules\node-fetch-npm\src\index.js:68:14)
npm ERR! at ClientRequest.emit (events.js:210:5)
npm ERR! at TLSSocket.socketErrorListener (_http_client.js:406:9)
npm ERR! at TLSSocket.emit (events.js:210:5)
npm ERR! at emitErrorNT (internal/streams/destroy.js:92:8)
npm ERR! at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
npm ERR! at processTicksAndRejections (internal/process/task_queues.js:80:21) {
npm ERR! message: 'request to https://registry.npmjs.org/element-plus failed, reason: connect ECONNREFUSED 127.0.0.1:443',
npm ERR! type: 'system',
npm ERR! errno: 'ECONNREFUSED',
npm ERR! code: 'ECONNREFUSED',
npm ERR! stack: 'FetchError: request to https://registry.npmjs.org/element-plus failed, reason: connect ECONNREFUSED 127.0.0.1:443\n' +
npm ERR! ' at ClientRequest.<anonymous> (D:\\Nodejs\\node_modules\\npm\\node_modules\\node-fetch-npm\\src\\index.js:68:14)\n' +
npm ERR! ' at ClientRequest.emit (events.js:210:5)\n' +
npm ERR! ' at TLSSocket.socketErrorListener (_http_client.js:406:9)\n' +
npm ERR! ' at TLSSocket.emit (events.js:210:5)\n' +
npm ERR! ' at emitErrorNT (internal/streams/destroy.js:92:8)\n' +
npm ERR! ' at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)\n' +
npm ERR! ' at processTicksAndRejections (internal/process/task_queues.js:80:21)'
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'
在错误中描述中不难看出 是因为proxy(代理)的问题,所以我们可以重点查看下 prxoy 的一个配置
解决方案:
1、查看proxy的配置情况:分别使用 npm config get proxy 和 npm config get https-proxy。如果两者返回 null ,则使用:npm config set registry 设置一个代理点。完成以后重复之前的操作命令即可
2、代理点出现:
FetchError: request to https://registry.npmjs.org/element-plus failed, reason: connect ECONNREFUSED 127.0.0.1:443,如果出现该情况,同样更换下代理点即可,如设置成淘宝的代理点:npm config set registry https://registry.npm.taobao.org
总结:
1、该问题主要述说的是npm proxy 的一个配置使用问题。
2、代理点不能使用的问题更换问题。
3、相关知识点:npm config get proxy、npm config get https-proxy 、npm config set registry