Installing CasperJS on RHEL Linux distribution

First you have to install NodeJS. You can do that via package manager for your distribution. In my case (RHEL) it is easily done with:

sudo yum install nodejs npm --enablerepo=epel

Installing CasperJS is easy via npm (Node package manager):

sudo npm install -g casperjs

You will get output similar to this:

Copying extracted folder /usr/lib/node_modules/casperjs/node_modules/phantomjs/phantomjs/phantomjs-1.9.7-linux-x86_64.tar.bz2-extract-1396259124118/phantomjs-1.9.7-linux-x86_64 -> /usr/lib/node_modules/casperjs/node_modules/phantomjs/lib/phantom
Writing location.js file
Done. Phantomjs binary available at /usr/lib/node_modules/casperjs/node_modules/phantomjs/lib/phantom/bin/phantomjs
/usr/bin/casperjs -> /usr/lib/node_modules/casperjs/bin/casperjs
npm WARN unmet dependency /usr/lib/node_modules/block-stream requires inherits@'~2.0.0' but will load
npm WARN unmet dependency undefined,
npm WARN unmet dependency which is version undefined
npm WARN unmet dependency /usr/lib/node_modules/fstream requires inherits@'~2.0.0' but will load
npm WARN unmet dependency undefined,
npm WARN unmet dependency which is version undefined
npm WARN unmet dependency /usr/lib/node_modules/fstream-ignore requires inherits@'2' but will load
npm WARN unmet dependency undefined,
npm WARN unmet dependency which is version undefined
npm WARN unmet dependency /usr/lib/node_modules/fstream-npm requires inherits@'2' but will load
npm WARN unmet dependency undefined,
npm WARN unmet dependency which is version undefined
npm WARN unmet dependency /usr/lib/node_modules/glob requires inherits@'2' but will load
npm WARN unmet dependency undefined,
npm WARN unmet dependency which is version undefined
npm WARN unmet dependency /usr/lib/node_modules/npmconf requires inherits@'~2.0.0' but will load
npm WARN unmet dependency undefined,
npm WARN unmet dependency which is version undefined
npm WARN unmet dependency /usr/lib/node_modules/tar requires inherits@'2' but will load
npm WARN unmet dependency undefined,
npm WARN unmet dependency which is version undefined
[email protected] /usr/lib/node_modules/casperjs
âââ [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
[[email protected] ~]$ casperjs
Fatal: [Errno 2] No such file or directory; did you install phantomjs?
[[email protected] ~]$ /usr/bin/casperjs
Fatal: [Errno 2] No such file or directory; did you install phantomjs?
[[email protected] ~]$ /usr/lib/node_modules/casperjs/node_modules/phantomjs/lib/phantom/bin/phantomjs
phantomjs>
[[email protected] ~]$ /usr/lib/node_modules/casperjs/node_modules/phantomjs/lib/phantom/bin/phantomjs --version
1.9.7

To have the binaries in my path every time I log in I added this alias to my .bashrc:

alias phantomset="export PATH=$PATH:/usr/lib/node_modules/casperjs/node_modules/phantomjs/lib/phantom/bin/"

and my .bash_profile looks like this:

# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
phantomset
Written by Nikola Brežnjak