最近在公司使用gruntjs
进行前端开发,其中有个前端单元测试插件grunt-contrib-qunit,它使用到了phantomjs,安装的时候报了一个错:

代码 复制 - 运行

> phantomjs@1.9.7-1 install D:\ssologin\node_modules\grunt-contrib-qunit\node_modules\grunt-lib-phantomjs\node_modules\phantomjs
> node install.js
 
Downloading http://cdn.bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.7-windows.zip
Saving to C:\Users\ADMINI~1\AppData\Local\Temp\phantomjs\phantomjs-1.9.7-windows.zip
 
events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: connect ETIMEDOUT
    at errnoException (net.js:904:11)
    at Object.afterConnect [as oncomplete] (net.js:895:19)
npm ERR! phantomjs@1.9.7-1 install: `node install.js`
npm ERR! Exit status 8
npm ERR!
npm ERR! Failed at the phantomjs@1.9.7-1 install script.
npm ERR! This is most likely a problem with the phantomjs package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node install.js
npm ERR! You can get their info via:
npm ERR!     npm owner ls phantomjs
npm ERR! There is likely additional logging output above.
 
npm ERR! System Windows_NT 6.1.7601
npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! cwd D:\ssologin
npm ERR! node -v v0.10.26
npm ERR! npm -v 1.4.3
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     D:\ssologin\npm-debug.log
npm ERR! not ok code 0

这个错是因为网络问题导致的(因为我们在墙内),解决办法就是手动下载phantomjs-1.9.7-windows.zip
,复制到C:\Users\ADMINI~1\AppData\Local\Temp\phantomjs\目录,再次执行npm install,安装成功,如下:


代码 复制 - 运行

> phantomjs@1.9.7-1 install D:\ssologin\node_modules\grunt-contrib-qunit\node_modules\grunt-lib-phantomjs\node_modules\phantomjs
> node install.js
 
Download already available at C:\Users\ADMINI~1\AppData\Local\Temp\phantomjs\phantomjs-1.9.7-windows.zip
Extracting zip contents
Copying extracted folder C:\Users\ADMINI~1\AppData\Local\Temp\phantomjs\phantomjs-1.9.7-windows.zip-extract-1394687379234\phantomjs-1.9.7-windows -> D:\ssologin\node_modules\grunt-contrib-qunit\node_modules\grunt-lib-phantomjs\node_modules\phantomjs\lib\phantom
Writing location.js file
Done. Phantomjs binary available at D:\ssologin\node_modules\grunt-contrib-qunit\node_modules\grunt-lib-phantomjs\node_modules\phantomjs\lib\phantom\phantomjs.exe
grunt-contrib-qunit@0.3.0 node_modules\grunt-contrib-qunit
└── grunt-lib-phantomjs@0.4.0 (eventemitter2@0.4.13, semver@1.0.14, temporary@0.0.8, phantomjs@1.9.7-1)



下载phantomjs-1.9.7-windows.zip
必须挂代理或者VPN,比较麻烦,大家可以从我的网盘下载,里面包括各种系统下的版本。


我的在:C:\Users\Fisher\AppData\Local\Temp\phantomjs
phantomjs-1.9.8-windows.zip (您是游客您没有权限下载)





http://keenwon.com/947.html