报错
使用npm命令安装插件报错FetchError: request to https://registry.npm.taobao.org/pnpm failed, reason: connect ECONNREFUSED 127.0.0.1:31181。
C:\WINDOWS\system32>npm install -g pnpm npm ERR! code ECONNREFUSED npm ERR! errno ECONNREFUSED npm ERR! FetchError: request to https://registry.npm.taobao.org/pnpm failed, reason: connect ECONNREFUSED 127.0.0.1:31181 npm ERR! at ClientRequest.<anonymous> (C:\Users\xiaop\AppData\Roaming\nvm\v14.7.0\node_modules\npm\node_modules\node-fetch-npm\src\index.js:68:14) npm ERR! at ClientRequest.emit (events.js:314:20) npm ERR! at onerror (C:\Users\xiaop\AppData\Roaming\nvm\v14.7.0\node_modules\npm\node_modules\agent-base\index.js:101:9) npm ERR! at callbackError (C:\Users\xiaop\AppData\Roaming\nvm\v14.7.0\node_modules\npm\node_modules\agent-base\index.js:123:5) npm ERR! at processTicksAndRejections (internal/process/task_queues.js:93:5) npm ERR! FetchError: request to https://registry.npm.taobao.org/pnpm failed, reason: connect ECONNREFUSED 127.0.0.1:31181 npm ERR! at ClientRequest.<anonymous> (C:\Users\xiaop\AppData\Roaming\nvm\v14.7.0\node_modules\npm\node_modules\node-fetch-npm\src\index.js:68:14) npm ERR! at ClientRequest.emit (events.js:314:20) npm ERR! at onerror (C:\Users\xiaop\AppData\Roaming\nvm\v14.7.0\node_modules\npm\node_modules\agent-base\index.js:101:9) npm ERR! at callbackError (C:\Users\xiaop\AppData\Roaming\nvm\v14.7.0\node_modules\npm\node_modules\agent-base\index.js:123:5) npm ERR! at processTicksAndRejections (internal/process/task_queues.js:93:5) { npm ERR! type: 'system', npm ERR! errno: 'ECONNREFUSED', npm ERR! code: 'ECONNREFUSED' 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: npm ERR! C:\Users\xiaop\AppData\Roaming\npm-cache\_logs\2023-01-12T05_16_30_862Z-debug.log
原因
报错最后有个关键提示:If you are behind a proxy, please make sure that the 'proxy' config is set properly. See: 'npm help config'
所以可能是npm没有配置好,出现了代理问题
解决
清理代理,并重新设置
//1.清理以前的代理设置:先通过以下代码查看代理设置,如果返回null那就不需要清理,直接跳到第三步 npm config get proxynpm config get https-proxy //2.清除以前的代理设置 npm config set proxy null npm config set https-proxy null npm config delete proxy npm config delete https-proxy //3.重新设置,也可设置淘宝源 https://registry.npm.taobao.org/ npm config set registry http://registry.npmjs.org/ npm config set registry "http://registry.npmjs.org/"
好了,现在可以重新运行npn命令进行安装了