繁体   English   中英

child_process.execFile不适用于phantomjs和highcharts-convert.js

[英]child_process.execFile is not working with phantomjs and highcharts-convert.js

我写了一个生成高图图像的nodejs程序,看起来像这样。

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输出。 但是当我运行程序时,我在标准输出中得到空字符串。 那么,还有其他需要配置的东西吗?

提前致谢..

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

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

您可以检查超时值吗?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM