从 NodeJS child_process.spawn 中检索 bash 错误
Retrieve bash error from NodeJS child_process.spawn
当我从 bash 执行(编造的和荒谬的)命令 banana
时,我收到以下错误:
bash: banana: command not found
但是如果我在 Node.js 中的 child_process.spawn
中执行 banana
,我会得到错误:
net.js:624
throw new TypeError('invalid data');
^
TypeError: invalid data
at WriteStream.Socket.write (net.js:624:11)
at ChildProcess.<anonymous>
at ChildProcess.emit (events.js:107:17)
at Process.ChildProcess._handle.onexit (child_process.js:1065:12)
at child_process.js:1137:20
at process._tickCallback (node.js:355:11)
at Function.Module.runMain (module.js:503:11)
at startup (node.js:129:16)
at node.js:814:3
有没有办法从 Node.JS 中获取原始 bash 错误的文本?
附加到 child_process.spawn 的 'error' 事件发射器将为您提供以下消息:
child_process_instance.on('error', function (error) {
console.log(error);
});
Error: spawn bananas ENOENT
当我从 bash 执行(编造的和荒谬的)命令 banana
时,我收到以下错误:
bash: banana: command not found
但是如果我在 Node.js 中的 child_process.spawn
中执行 banana
,我会得到错误:
net.js:624
throw new TypeError('invalid data');
^
TypeError: invalid data
at WriteStream.Socket.write (net.js:624:11)
at ChildProcess.<anonymous>
at ChildProcess.emit (events.js:107:17)
at Process.ChildProcess._handle.onexit (child_process.js:1065:12)
at child_process.js:1137:20
at process._tickCallback (node.js:355:11)
at Function.Module.runMain (module.js:503:11)
at startup (node.js:129:16)
at node.js:814:3
有没有办法从 Node.JS 中获取原始 bash 错误的文本?
附加到 child_process.spawn 的 'error' 事件发射器将为您提供以下消息:
child_process_instance.on('error', function (error) {
console.log(error);
});
Error: spawn bananas ENOENT