我在我的 Ubuntu16.04 上已经配置好了 cnpm,在通过 cnpm 安装 Appium 的时候会出现以下的错误:
hu@hu-Vostro-3900:~$ cnpm install -g appium@1.4.16
⠸ Installing appium@1.4.16[npminstall:get] retry GET http://registry.npm.taobao.org/appium/download/appium-1.4.16.tgz after 100ms, retry left 4, error: ResponseError: read ECONNRESET (req "error"), GET http://registry.npm.taobao.org/appium/download/appium-1.4.16.tgz -1 (connected: true, keepalive socket: false, agent status: {"createSocketCount":1,"closeSocketCount":0,"errorSocketCount":0,"timeoutSocketCount":0,"requestCount":0,"freeSockets":{},"sockets":{"registry.npm.taobao.org:80::":1},"requests":{}})
headers: {}
⠼ Installing appium@1.4.16[npminstall:get] retry GET http://registry.npm.taobao.org/appium/download/appium-1.4.16.tgz after 200ms, retry left 3, error: ResponseError: read ECONNRESET (req "error"), GET http://registry.npm.taobao.org/appium/download/appium-1.4.16.tgz -1 (connected: true, keepalive socket: false, agent status: {"createSocketCount":2,"closeSocketCount":1,"errorSocketCount":0,"timeoutSocketCount":0,"requestCount":0,"freeSockets":{},"sockets":{"registry.npm.taobao.org:80::":1},"requests":{}})
headers: {}
⠧ Installing appium@1.4.16[npminstall:get] retry GET http://registry.npm.taobao.org/appium/download/appium-1.4.16.tgz after 300ms, retry left 2, error: ResponseError: read ECONNRESET (req "error"), GET http://registry.npm.taobao.org/appium/download/appium-1.4.16.tgz -1 (connected: true, keepalive socket: false, agent status: {"createSocketCount":3,"closeSocketCount":2,"errorSocketCount":0,"timeoutSocketCount":0,"requestCount":0,"freeSockets":{},"sockets":{"registry.npm.taobao.org:80::":1},"requests":{}})
headers: {}
⠙ Installing appium@1.4.16[npminstall:get] retry GET http://registry.npm.taobao.org/appium/download/appium-1.4.16.tgz after 400ms, retry left 1, error: ResponseError: read ECONNRESET (req "error"), GET http://registry.npm.taobao.org/appium/download/appium-1.4.16.tgz -1 (connected: true, keepalive socket: false, agent status: {"createSocketCount":4,"closeSocketCount":3,"errorSocketCount":0,"timeoutSocketCount":0,"requestCount":0,"freeSockets":{},"sockets":{"registry.npm.taobao.org:80::":1},"requests":{}})
headers: {}
⠦ Installing appium@1.4.16Error: read ECONNRESET
at exports._errnoException (util.js:1026:11)
at TCP.onread (net.js:563:26)
npminstall version: 2.11.2
npminstall args: /home/hu/.linuxbrew/Cellar/node/6.4.0/bin/node /home/hu/.linuxbrew/lib/node_modules/cnpm/node_modules/.bin/npminstall --china --userconfig=/home/hu/.cnpmrc --disturl=https://npm.taobao.org/mirrors/node --registry=https://registry.npm.taobao.org -g appium@1.4.16
hu@hu-Vostro-3900:~$
可以看到,cnpm 在获取包的链接为
http://registry.npm.taobao.org/appium/download/appium-1.4.16.tgz
这个链接即使放到浏览器上也是无法访问的,然后我把链接改为
https://registry.npm.taobao.org/appium/download/appium-1.4.16.tgz # 变成 HTTPS 的请求
可以正常下载 Appium 的包,所以这里存在的问题是 cnpm 没有使用正确的传输协议导致这个错误,想问下各位有没有遇到过这种情况的?应该怎么解决呢?