簡體   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