3

There isn't a clear guide on how to install Phantom for Meteor, so I decided to ask a question to clarify things.

  1. Do you have to install phantom binary in /usr/local/bin/? I downloaded a compiled phantomjs from the official website and placed inside the above path. I can run phantomjs from anywhere now because it's added to path.

  2. In addition to 1, do you also have to install it from meteor npm? I followed this to install "phantomjs": "1.9.13" as a npm package inside my Meteor app. It gets confusing from here because the binary from the official website is v2.0.0 while the npm package is 1.9.13. Do I need to install both?

  3. Because of the confusion in 2, I removed /usr/local/bin/phantomjs but then I can't run $phantomjs anywhere because I don't have anything in PATH.

My ultimate goal is to get spiderable working. What should I do?

Community
  • 1
  • 1
Maximus S
  • 10,759
  • 19
  • 75
  • 154
  • Well, do you want to use PhantomJS 1.9.8 (npm package 1.9.13 or later) or do you want to use PhantomJS 2? I don't see a 2.0 binary for linux on the official page. I have no idea about spiderable, though. – Artjom B. Apr 21 '15 at 14:59

5 Answers5

2

Okay, the problem was the compiled phantomjs binary from the official webpage cannot be used right away in the latest Mac OS, but you have to unpack it first. To run spiderable package you don't need to do anything other than placing the binary file phantomjs inside your local path /usr/bin/local/. You can test this by running $phantomjs in your terminal. If you see phantomjs not found then you haven't installed it. If you see an error killed 9 then you have the same problem as mine, and you can solve it by following this.

You do not need the meteorhacks:npm package.

Community
  • 1
  • 1
Maximus S
  • 10,759
  • 19
  • 75
  • 154
1

You can do this in two ways:

Method 1:

If you'd like to be able to use PhantomJS via your Meteor app, you would need to use the Meteorhacks NPM package and use the latest NPM version 1.9.16 I believe.

After that, you can edit your packages.json file to add "phantomjs": "1.9.16", and then reference it via var phantomjs = Meteor.npmRequire('phantomjs');

Method 2:

Alternatively, you can use the smart package for Meteor PhantomJS and give that a shot.

I personally feel like Method 1 is a better option, as that worked for me. I needed PhantomJS for an app, and that solution worked for me. I haven't tried Method 2 so I can't speak for it, but it looks promising as well.

Give them a shot, and let me know how it goes. Hope that helps!

giantsnyc
  • 203
  • 1
  • 7
  • Thank you. Like I mentioned in the question, I already tried method 1 but `spiderable` package complains that `phatnomjs` is not installed, and I assume that's because `phantomjs` is not in `PATH`. How do I address the issue? – Maximus S Apr 21 '15 at 14:26
0

Here is a phantomjs wrapper package from atmosphere: https://atmospherejs.com/gadicohen/phantomjs

More importantly here is the spiderable package: https://atmospherejs.com/meteor/spiderable

I couldn't really answer the questions but more so point ya in a direction that I hope will solve your problem :)

cwahlfeldt
  • 580
  • 5
  • 14
0

In the terminal:

$ meteor npm install --save phantomjs

In your_meteor_app/server/main.js file (or wherever, provided it's server-side)

import phantom from 'phantom'

Day Davis Waterbury
  • 2,052
  • 18
  • 31
-1

Just use npm:

//Global effect on your machine

npm install -g phantomjs

//Test if installed

npm list -g

//Test spiderable working correctly

Test spiderable

Mo.
  • 26,306
  • 36
  • 159
  • 225
Roman S
  • 212
  • 2
  • 4