【问题标题】:child_process.execFile is not working with phantomjs and highcharts-convert.jschild_process.execFile 不适用于 phantomjs 和 highcharts-convert.js
【发布时间】:2016-02-02 03:18:14
【问题描述】:

我写了一个nodejs程序来生成highcharts图像。它看起来像这样。

var phantom = require('phantomjs');
var childProcess = require('child_process');
var childArgs = [
    '/usr/bin/Export/highcharts-convert.js',
    '-infile',
    '/usr/bin/infile.json',
    '-outfile',
    '.png',
    '-constr',
    'Chart',
    '-callback',
    '/usr/bin/callback.js'
];
childProcess.execFile(phantom.path, childArgs, null, function(error, stdout, stderr) {
    console.log(error);
    console.log(stdout);
    console.log(stderr);
}

在这里,我将标准输出作为空字符串。

但是当我从终端执行相同的命令时,我在控制台上得到了 png 输出。 从终端:

/usr/bin/Export/node_modules/phantomjs/lib/phantom/bin/phantomjs /usr/bin/Export/highcharts-convert.js -infile /usr/bin/infile.json -outfile .png -constr Chart -callback /usr/bin/callback.js

通过在终端上执行这个命令,我得到了 png 输出。但是当我运行程序时,我在标准输出中得到了空字符串。那么是否需要进行任何额外的配置?

提前谢谢..

【问题讨论】:

  • console.log(phantom.path); 的输出是什么?
  • 你成功了吗?我现在也有类似的情况,正在寻找解决方案。谢谢。
  • 我也遇到了类似的问题,有人能找到解决办法吗?

标签: javascript node.js highcharts phantomjs child-process


【解决方案1】:

将超时从 30000 设置为 0,对我有用。幻影脚本执行需要一点时间,

childProcess.execFile(phantomjs.path, args, {timeout: 0 }, function(outErr, stdout, stderr) {})

你能检查一下你的超时值吗?

【讨论】:

    猜你喜欢
    • 2016-11-10
    • 1970-01-01
    • 2013-01-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多