解决npm安装chromedriver下载失败的问题
使用npm安装chromedriver,下载chromedriver失败,报错信息:
> chromedriver@2.21.2 install /Users/user/cc/mydemo/node_modules/chromedriver
> node install.js
Downloading http://chromedriver.storage.googleapis.com/2.21/chromedriver_mac32.zip
Saving to /var/folders/f2/_jd2rvp15jg_pzsfr2zm7cnh0000gn/T/chromedriver/chromedriver_mac32.zip
Receiving...
Received 781K...
Received 1563K...
events.js:160
throw er; // Unhandled 'error' event
^
Error: read ECONNRESET
at exports._errnoException (util.js:1008:11)
at TCP.onread (net.js:563:26)
npm ERR! Darwin 15.3.0
npm ERR! argv "/usr/local/Cellar/node/6.3.0/bin/node" "/usr/local/bin/npm" "install"
npm ERR! node v6.3.0
npm ERR! npm v3.10.3
npm ERR! code ELIFECYCLE
从错误信息可以看到,报错的原因是出现在下载chromedriver时。下载的路径为google的服务器,所以导致下载失败的原因有可能是没有科学上网。
把chromedriver下载路径改为淘宝的镜像执行:
npm install chromedriver --chromedriver_cdnurl=http://cdn.npm.taobao.org/dist/chromedriver
安装成功!