【发布时间】:2014-08-03 16:25:15
【问题描述】:
我正在尝试将我的 phantomjs 脚本中的结果缓冲到 nodejs,但由于某种原因,即使似乎没有错误,缓冲结果也会不断来自 STDERR 而不是 STDOUT。
NodeJS 代码:
var exec = require('child_process').exec;
exec('phantomjs console.js', function(stdout, stderr, error){
if (error !== null) {
console.log('exec error: ' + error);
}
console.log("Standard Output: " + stdout + " ");
console.log("Error Output: " + stderr + " ");
});
PhantomJS 代码(console.js):
console.log("Hello world!");
phantom.exit();
我得到的结果:
exec error:
Standard Output: null
Error Output: Hello world!
【问题讨论】:
-
你有反向定义的正式参数:在节点中,错误首先出现。
-
嗨,Dan,我什至尝试切换 stdout 和 stderr 的 console.log 的位置,仍然得到相同的结果。
标签: javascript node.js phantomjs stdout child-process