美文网首页
cnpminstall报错:Connecttimeoutfor5

cnpminstall报错:Connecttimeoutfor5

作者: 简书超级会员 | 来源:发表于2019-07-26 10:01 被阅读0次

这次发布项目自动化打包,cnpm install 报错,报错如下

Get /binary-mirror-config/latest from https://registry.npm.taobao.org error: ConnectionTimeoutError: Connect timeout for 5000ms, GET https://registry.npmjs.com/binary-mirror-config/latest -2 (connected: false, keepalive socket: false, agent status: {"createSocketCount":4,"createSocketErrorCount":0,"closeSocketCount":4,"errorSocketCount":0,"timeoutSocketCount":0,"requestCount":0,"freeSockets":{},"sockets":{},"requests":{}}, socketHandledRequests: 1, socketHandledResponses: 0)……

执行命令

time curl -v https://registry.npm.taobao.org/binary-mirror-config/latest
测试网络

{"latest":"1.20.0"}}
real    0m10.716s
user    0m0.054s
sys 0m0.084s

然后找到报错根源:/nodejs/lib/node_modules/cnpm/node_modules/urllib/lib/urllib.js

修改掉文件里面的常量 TIMEOUT、TIMEOUTS 的 5s 为 10s

然后&……

大功告成 !

# npm 不能下载的时候这样做
rm  package-lock.json
rm -rf node_modules
npm cache clear --force

相关文章

网友评论

      本文标题:cnpminstall报错:Connecttimeoutfor5

      本文链接:https://www.haomeiwen.com/subject/jcxrrctx.html