使用 Grunt 时,安装 phantomjs 失败的解决办法

2014-03-13 · 359 chars · 2 min read

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

> [email protected] 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! [email protected] install: `node install.js`
npm ERR! Exit status 8
npm ERR!
npm ERR! Failed at the [email protected] 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,安装成功,如下:

> [email protected] 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
[email protected] node_modules\grunt-contrib-qunit
└── [email protected] ([email protected], [email protected], [email protected], [email protected])

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

赞赏

微信