1

I successfully created a script using phantomjs-node in local and I would like to host on OpenShift.

The thing is when I run my script hosted, I had this strange error:

phantom stderr: execvp(): No such file or directory phantomjs-node: You don't have 'phantomjs' installed

But as you can see, I put the dependancies in the package.json file:

"dependencies": {
  "express": "~3.4.4",
  "phantom": "*",
  "phantomjs": "*"
},

Any suggestions?

Edit:

This is how I initialize the phantomjs script:

var options = {
  port: 16000,
  hostname: "127.2.149.1",
  path: "/phantom_path/"
}
phantom.create(function(ph) {
  visitUrl(ph, 0, 0);
}, options);
Jean Lebrument
  • 5,079
  • 8
  • 33
  • 67
  • I'm not sure you can install phantomjs like that. I had to download the phantomjs executable and install it in the openshift Data directory separately for my python project. – fat fantasma Apr 02 '15 at 10:57
  • Maybe this SO question will help. http://stackoverflow.com/questions/11259818/is-it-possible-to-run-phantomjs-from-node-js-as-a-command-line-argument – fat fantasma Apr 02 '15 at 11:14
  • Thank for you answer, but I already use phantomjs-node. And it successfully worked on my machine but I've got this error message only when I try my script once hosted on OpenShift. – Jean Lebrument Apr 04 '15 at 02:40
  • I'm thinking it must be a path, port, or host problem then. I have never used phantoms-mode. I just have worked with phantoms and python. – fat fantasma Apr 05 '15 at 12:08

2 Answers2

2

The error message You don't have 'phantomjs' installed is an internal error from the phantomjs-node module. I ran into this error myself, and I managed to fix it like this:

var phantom = require('phantom');

var options = {
        path: '/usr/local/bin/'
};

phantom.create(function (ph) {
    ph.createPage(function (page) {
        page.open("http://www.google.com", function (status) {
            console.log("opened google? ", status);
            page.evaluate(function () { return document.title; }, function (result) {
                console.log('Page title is ' + result);
                ph.exit();
            });
        });
    });
}, options);

Notice the options being passed to the phantom.create() method. The path option should be the full path to the directory that contains your phantomjs binary.

c.hill
  • 3,127
  • 25
  • 31
0

Phantomjs-node is looking for Phantomjs on the PATH of your Open Shift environment and cannot find it. Look for a way to add Phantomjs on this PATH.

GracefulCode
  • 141
  • 7