基于这篇文章:http://blog.csdn.net/qdujunjie/article/details/46806441
安装完nodejs和npm之后,我们来安装yslowjs。
参考这篇文章:http://mervine.net/projects/npms/yslowjs
sudo npm install yslowjs
安装成功:
[wz@supportserver-51 node-v0.12.6]$ sudo npm install yslowjs
-\|/-\|/-\|/-\-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-npm WARN engine phapper@0.1.11: wanted: {"node":">=0.10 <0.11"} (current: {"node":"0.12.6","npm":"2.11.2"})
-\|/-\|/-\|/-\|/
> phapper@0.1.11 install /usr/local/nodejs/node-v0.12.6/node_modules/yslowjs/node_modules/phapper
> node install.js
which: no phantomjs in (/usr/local/lib/node_modules/npm/bin/node-gyp-bin:/usr/local/nodejs/node-v0.12.6/node_modules/yslowjs/node_modules/phapper/node_modules/.bin:/usr/local/nodejs/node-v0.12.6/node_modules/yslowjs/node_modules/.bin:/usr/local/nodejs/node-v0.12.6/node_modules/.bin:/usr/bin:/bin:/usr/sbin:/sbin)
--2015-07-08 17:41:54-- https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.8-linux-x86_64.tar.bz2
Resolving bitbucket.org... 131.103.20.167, 131.103.20.168
Connecting to bitbucket.org|131.103.20.167|:443... connected.
HTTP request sent, awaiting response... 302 FOUND
Location: https://bbuseruploads.s3.amazonaws.com/ariya/phantomjs/downloads/phantomjs-1.9.8-linux-x86_64.tar.bz2?Signature=ivgec%2Bt6KsGzdLA4Pw3sl%2FWrrXU%3D&Expires=1436349487&AWSAccessKeyId=0EMWEFSGA12Z1HF1TZ82&response-content-disposition=attachment%3B%20filename%3D%22phantomjs-1.9.8-linux-x86_64.tar.bz2%22 [following]
--2015-07-08 17:41:58-- https://bbuseruploads.s3.amazonaws.com/ariya/phantomjs/downloads/phantomjs-1.9.8-linux-x86_64.tar.bz2?Signature=ivgec%2Bt6KsGzdLA4Pw3sl%2FWrrXU%3D&Expires=1436349487&AWSAccessKeyId=0EMWEFSGA12Z1HF1TZ82&response-content-disposition=attachment%3B%20filename%3D%22phantomjs-1.9.8-linux-x86_64.tar.bz2%22
Resolving bbuseruploads.s3.amazonaws.com... 54.231.1.65
Connecting to bbuseruploads.s3.amazonaws.com|54.231.1.65|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 13163325 (13M) [application/x-tar]
Saving to: “phantomjs-1.9.8-linux-x86_64.tar.bz2?Signature=ivgec+t6KsGzdLA4Pw3sl%2FWrrXU=&Expires=1436349487&AWSAccessKeyId=0EMWEFSGA12Z1HF1TZ82&response-content-disposition=attachment; filename="phantomjs-1.9.8-linux-x86_64.tar.bz2"”
100%[====================================================================================================================================================>] 13,163,325 1.13M/s in 14s
2015-07-08 17:42:15 (940 KB/s) - “phantomjs-1.9.8-linux-x86_64.tar.bz2?Signature=ivgec+t6KsGzdLA4Pw3sl%2FWrrXU=&Expires=1436349487&AWSAccessKeyId=0EMWEFSGA12Z1HF1TZ82&response-content-disposition=attachment; filename="phantomjs-1.9.8-linux-x86_64.tar.bz2"” saved [13163325/13163325]
Decompressing phantomjs-1.9.8-linux-x86_64.tar.bz2...
tar (child): phantomjs-1.9.8-linux-x86_64.tar.bz2: Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
Error occured decompressing phantomjs-1.9.8-linux-x86_64.tar.bz2.
> yslowjs@0.3.2 install /usr/local/nodejs/node-v0.12.6/node_modules/yslowjs
> node install.js
yslow.js is installed.
=> /usr/local/nodejs/node-v0.12.6/node_modules/yslowjs/lib/yslow_phantom.js
You can reference it within node like so:
var YSlow = require('yslow');
var yslow = new YSlow(url, args);
console.log(yslow.yslowjs);
yslowjs@0.3.2 node_modules/yslowjs
└── phapper@0.1.11 (sync-exec@0.5.0)
[wz@supportserver-51 node-v0.12.6]$