0

I have a project that need node.js, PhantomJS and CasperJS.

I have node.js working. I run following commands

npm install phantomjs
npm install casperjs

but that project is not working. It gives the error:

casperjs module not found

Can anybody tell me what to do?

Artjom B.
  • 61,146
  • 24
  • 125
  • 222
  • PhantomJS and CasperJS don't really make sense locally. You should install them globally. What does this give you: `npm show casperjs`? – Artjom B. Apr 11 '15 at 10:32
  • it gives something like jason object 'name : .. ... , description ... ' etc –  Apr 11 '15 at 10:54

2 Answers2

0

Following things/steps help me to install and run casperjs on my windows machine properly:

Requirements:

  • Node Package Manager
  • PhantomJS

step 01: Install node package manager by following this simple 4 min video

step 02: Install phantomJS using the following command npm install phantomjs2. Check this link for more details.

step 03: Run the following command npm install casperjs

To get the phantomjs and casperjs module in command line, add this to windows bin path. To edit the bin path follow this:

  1. Right click on my computer and click on Properties
  2. go to advanced system settings
  3. click Enviroment variables
  4. from system variables section, select path and click on Edit
  5. now add caseperjs and phantomjs path like this at the end of path variable: ;C:\WINDOWS_GLOBAL_NODE_MODULES_PATH\casperjs\bin;C:\WINDOWS_GLOBAL_NODE_MODULES_PATH\phantomjs\bin. where WINDOWS_GLOBAL_NODE_MODULES_PATH = Your machine node modules path.
  6. To get this path run npm list -g. First line of the command output is the path.

Now you are all set and check the casperjs command in command line.

Note: NPM is the best tool for javascript based development. so once you set it up, every new thing is easy to setup.

Community
  • 1
  • 1
M.M.H.Masud
  • 329
  • 3
  • 8
  • 22
-1

The casperjs@1.1.0-beta3 package depends on phantomjs>=1.8.2. If you installed CasperJS earlier, it will try to install CasperJS with the PhantomJS version from before. In my case that was phantomjs@1.9.6-0 which is not possible to install through NPM anymore.

You need to clear the npm-cache for the casperjs package. Go to C:\users\{you}\AppData\Roaming\npm-cache and delete the casperjs folder. Now when you try to install CasperJS, it will fetch the newest NPM package of PhantomJS which is currently 1.9.16 (it is PhantomJS 1.9.8). This won't get you much though, because

PhantomJS and CasperJS make really only sense when installed globally. You can do this for example with npm:

npm -g install phantomjs
npm -g install casperjs

Or completely skip the PhantomJS step, because CasperJS will fetch its own PhantomJS dependency.


If you want to try PhantomJS 2 (CasperJS 1.1.0-beta3 only supports PhantomJS 1.x), then you will need to install everything yourself. Download PhantomJS 2 from the official page and put the executable into a directory which is in the PATH environment variable.

Then install CasperJS from git and put its path into the PATH environment variable.

Artjom B.
  • 61,146
  • 24
  • 125
  • 222