npm i 安装报错RequestError: socket hang up

发布时间 2023-04-08 17:25:03作者: Questions张

1 异常信息

npm WARN deprecated @npmcli/move-file@2.0.1: This functionality has been moved to @npmcli/fs
npm WARN deprecated asar@3.2.0: Please use @electron/asar moving forward.  There is no API change, just a package name change
npm ERR! code 1
npm ERR! path /Users/zhangjin/mycode/github/cursor/node_modules/electron
npm ERR! command failed
npm ERR! command sh -c -- node install.js
npm ERR! RequestError: socket hang up
npm ERR!     at ClientRequest.<anonymous> (/Users/zhangjin/mycode/github/cursor/node_modules/got/dist/source/core/index.js:970:111)
npm ERR!     at Object.onceWrapper (node:events:628:26)
npm ERR!     at ClientRequest.emit (node:events:525:35)
npm ERR!     at ClientRequest.origin.emit (/Users/zhangjin/mycode/github/cursor/node_modules/@szmarczak/http-timer/dist/source/index.js:43:20)
npm ERR!     at TLSSocket.socketOnEnd (node:_http_client:518:9)
npm ERR!     at TLSSocket.emit (node:events:525:35)
npm ERR!     at endReadableNT (node:internal/streams/readable:1358:12)
npm ERR!     at connResetException (node:internal/errors:705:14)
npm ERR!     at TLSSocket.socketOnEnd (node:_http_client:518:23)
npm ERR!     at TLSSocket.emit (node:events:525:35)
npm ERR!     at endReadableNT (node:internal/streams/readable:1358:12)
npm ERR!     at processTicksAndRejections (node:internal/process/task_queues:83:21)

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/xxxx/.npm/_logs/2023-04-08T09_03_45_778Z-debug-0.log

 2 是国内的网络访问外围问题导致,换成国内的镜像源地址就好了。 我是安装模块electron报错,其他的也可以配置相应镜像,或者设置全局的镜像。

export ELECTRON_MIRROR=https://npm.taobao.org/mirrors/electron/