npm install 尝试从 localhost 安装

Npm install tries to install from localhost

提问人:LokiTheShady 提问时间:11/13/2023 更新时间:11/13/2023 访问量:34

问:

当我尝试运行逗号时

npm install http

在给我这个错误之前,它挂起了一段时间

npm ERR! code ECONNREFUSED
npm ERR! errno ECONNREFUSED
npm ERR! FetchError: request to https://localhost/http failed, reason:
npm ERR!     at ClientRequest.<anonymous> (C:\Users\Barth\AppData\Roaming\npm\node_modules\npm\node_modules\minipass-fetch\lib\index.js:130:14)
npm ERR!     at ClientRequest.emit (node:events:514:28)
npm ERR!     at _destroy (node:_http_client:875:13)
npm ERR!     at onSocketNT (node:_http_client:895:5)
npm ERR!     at process.processTicksAndRejections (node:internal/process/task_queues:83:21)
npm ERR!  FetchError: request to https://localhost/http failed, reason:
npm ERR!     at ClientRequest.<anonymous> (C:\Users\Barth\AppData\Roaming\npm\node_modules\npm\node_modules\minipass-fetch\lib\index.js:130:14)
npm ERR!     at ClientRequest.emit (node:events:514:28)
npm ERR!     at _destroy (node:_http_client:875:13)
npm ERR!     at onSocketNT (node:_http_client:895:5)
npm ERR!     at process.processTicksAndRejections (node:internal/process/task_queues:83:21) {
npm ERR!   code: 'ECONNREFUSED',
npm ERR!   errno: 'ECONNREFUSED',
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'

如您所见,它尝试从 https://localhost/http 是什么原因造成的,我该如何解决这个问题

我已经尝试过完全重新安装节点

npm npm -安装

评论

0赞 stratov 11/13/2023
什么回报?npm config get registry
0赞 LokiTheShady 11/13/2023
"本地主机"
0赞 stratov 11/13/2023
您可以尝试使用此命令设置注册表吗?npm config set registry https://registry.npmjs.org/
0赞 LokiTheShady 11/13/2023
我已经能够重置它,谢谢只是不知道在哪里寻找修复是 npm set registy(在它之后注意,所以它重置)

答:

0赞 stratov 11/13/2023 #1

确保 npm 注册表设置正确。您可以使用以下命令检查和更新注册表:

npm config get registry

npm config set registry https://registry.npmjs.org/

我希望这对其他人也有帮助。