将phantomJS部署到node.js应用程序?

use*_*182 7 heroku node.js phantomjs casperjs

我意识到"在Heroku上运行PhantomJS"是一个相关但略有不同的问题,因为我正在尝试使用节点应用程序.

我在为节点应用程序部署casperJS(基于phantomJS)脚本时遇到问题.我已经尝试通过将PhantomJS 64位二进制文​​件放在我的应用程序/bin目录中来部署到Heroku ,但是当我尝试运行PhantomJS时出现以下错误:

phantomjs: error while loading shared libraries: libQtWebKit.so.4: cannot open shared object file: No such file or directory
Run Code Online (Sandbox Code Playgroud)

从我读过的内容可以通过安装QtWebKit库来解决,但是Heroku没有安装它.是否有其他我可以使用的托管服务提供商可以使用或在Heroku上安装此软件包的方法?

相关代码:

app.get('/', function(request, response) {
  var sys = require('sys')
  var exec = require('child_process').exec;
  var child;

  //works but gives error while loading shared library libqtwebkit.so.4
  child = exec("phantomjs --version | tr -d '\n'", function(error, stdout, stderr) {
    sys.print('stdout: ' + stdout);
    sys.print('stderr: ' + stderr + '\n');
    response.header('Content-Type', 'application/json');
    response.send('_testcb(stdout:' + stdout + '\nstderr:' + stderr + ')', 200);
    if(error !== null) {
      console.log('exec error: ' + error);
    }
  });
});
Run Code Online (Sandbox Code Playgroud)

我已经注册了Nodester上的beta测试,但他们的文档在这一点上仍然非常有限.

编辑:我能够通过简单地将PhantomJS的lib文件夹复制到我的节点应用程序的根目录来实现它.

Fun*_*bat 3

将 phantomjs 的 lib 文件夹复制到节点应用程序的根目录您也可以尝试将符号链接放入 bin 或 sbin 中,关键是它必须使用与节点运行相同的帐户从终端运行。另外,node-phantom 是一个很好的 npm 库,一旦你让它工作起来,就可以利用 phantomjs。