【问题标题】:Error in OpenShift: "phantomjs-node: You don't have 'phantomjs' installed"OpenShift 中的错误:“phantomjs-node:您没有安装 'phantomjs'”
【发布时间】:2015-03-31 02:49:29
【问题描述】:

我在本地使用 phantomjs-node 成功创建了一个脚本,我想在 OpenShift 上进行托管。

问题是当我运行托管脚本时,我遇到了这个奇怪的错误:

phantom stderr: execvp(): 没有这样的文件或目录 phantomjs-node: 你没有安装“phantomjs”

但是如你所见,我将依赖项放在package.json 文件中:

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

有什么建议吗?

编辑:

这就是我初始化 phantomjs 脚本的方式:

var options = {
  port: 16000,
  hostname: "127.2.149.1",
  path: "/phantom_path/"
}
phantom.create(function(ph) {
  visitUrl(ph, 0, 0);
}, options);

【问题讨论】:

  • 我不确定你能不能像那样安装 phantomjs。我必须为我的 python 项目下载 phantomjs 可执行文件并将其安装在 openshift Data 目录中。
  • 也许这个 SO 问题会有所帮助。 stackoverflow.com/questions/11259818/…
  • 谢谢你的回答,但我已经使用了phantomjs-node。它在我的机器上成功运行,但只有在我尝试托管在 OpenShift 上的脚本时才会收到此错误消息。
  • 我想那一定是路径、端口或主机问题。我从未使用过幻象模式。我刚刚使用过幻影和 python。

标签: node.js phantomjs openshift


【解决方案1】:

错误消息You don't have 'phantomjs' installed 是来自phantomjs-node 模块的内部错误。我自己遇到了这个错误,我设法修复它:

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);

注意options 被传递给phantom.create() 方法。 path 选项应该是包含您的 phantomjs 二进制文件的目录的完整路径。

【讨论】:

    【解决方案2】:

    Phantomjs-node 正在 Open Shift 环境的 PATH 中寻找 Phantomjs,但找不到。寻找一种在此 PATH 上添加 Phantomjs 的方法。

    【讨论】:

      猜你喜欢
      • 2015-04-18
      • 1970-01-01
      • 2018-06-23
      • 2014-05-31
      • 2016-06-05
      • 1970-01-01
      • 2017-12-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多