基于这篇文章:http://blog.csdn.net/qdujunjie/article/details/46806441
安装完nodejs和npm之后,我们来安装yslowjs。
参考这篇文章:http://mervine.net/projects/npms/yslowjs
sudo npm install yslowjs
安装成功:
[wz@supportserver- node-v0]$ sudo npm install yslowjs
-\|/-\|/-\|/-\-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-npm WARN engine [email protected]: wanted: {"node":">=0.10 <0.11"} (current: {"node":"0.12.6","npm":"2.11.2"})
-\|/-\|/-\|/-\|/
> [email protected] install /usr/local/nodejs/node-v0/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)
---- ::-- https://bitbucket.org/ariya/phantomjs/downloads/phantomjs--linux-x86_64.tar.bz2
Resolving bitbucket.org... ,
Connecting to bitbucket.org||:.. connected.
HTTP request sent, awaiting response... FOUND
Location: https://bbuseruploads.s3.amazonaws.com/ariya/phantomjs/downloads/phantomjs--linux-x86_64.tar.bz2?Signature=ivgec%Bt6KsGzdLA4Pw3sl%FWrrXU%D&Expires=&AWSAccessKeyId=EMWEFSGA12Z1HF1TZ82&response-content-disposition=attachment%B%filename%D%phantomjs--linux-x86_64.tar.bz2% [following]
---- ::-- https://bbuseruploads.s3.amazonaws.com/ariya/phantomjs/downloads/phantomjs--linux-x86_64.tar.bz2?Signature=ivgec%Bt6KsGzdLA4Pw3sl%FWrrXU%D&Expires=&AWSAccessKeyId=EMWEFSGA12Z1HF1TZ82&response-content-disposition=attachment%B%filename%D%phantomjs--linux-x86_64.tar.bz2%
Resolving bbuseruploads.s3.amazonaws.com...
Connecting to bbuseruploads.s3.amazonaws.com||:.. connected.
HTTP request sent, awaiting response... OK
Length: (M) [application/x-tar]
Saving to: “phantomjs--linux-x86_64.tar.bz2?Signature=ivgec+t6KsGzdLA4Pw3sl%FWrrXU=&Expires=&AWSAccessKeyId=EMWEFSGA12Z1HF1TZ82&response-content-disposition=attachment; filename="phantomjs-1.9.8-linux-x86_64.tar.bz2"”
%[====================================================================================================================================================>] ,, M/s in s
-- :: ( KB/s) - “phantomjs--linux-x86_64.tar.bz2?Signature=ivgec+t6KsGzdLA4Pw3sl%FWrrXU=&Expires=&AWSAccessKeyId=EMWEFSGA12Z1HF1TZ82&response-content-disposition=attachment; filename="phantomjs-1.9.8-linux-x86_64.tar.bz2"” saved [/]
Decompressing phantomjs--linux-x86_64.tar.bz2...
tar (child): phantomjs--linux-x86_64.tar.bz2: Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status
tar: Error is not recoverable: exiting now
Error occured decompressing phantomjs--linux-x86_64.tar.bz2.
> [email protected] install /usr/local/nodejs/node-v0/node_modules/yslowjs
> node install.js
yslow.js is installed.
=> /usr/local/nodejs/node-v0/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);
[email protected] node_modules/yslowjs
└── [email protected] ([email protected])
[wz@supportserver- node-v0]$