检索的NodeJS child_process.spawn庆典错误 [英] Retrieve bash error from NodeJS child_process.spawn

查看:1750
本文介绍了检索的NodeJS child_process.spawn庆典错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我执行(由可笑)命令香蕉从庆典,我得到了以下错误:

When I execute the (made up and ridiculous) command banana from bash I get the following error:

bash: banana: command not found

但是,如果我执行香蕉 child_process.spawn 在Node.js的,我得到的错误:

But if I execute banana in a child_process.spawn in Node.js, I get the error:

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

有没有什么办法让原来的bash错误的Node.js的从文?

Is there any way to get the text of the original bash error from Node.JS?

推荐答案

附加的'错误'事件发射的child_process.spawn会给你以下信息:

Attaching to the 'error' event emitter for the child_process.spawn will give you the following message:

child_process_instance.on('error', function (error) {
    console.log(error);
});

Error: spawn bananas ENOENT

这篇关于检索的NodeJS child_process.spawn庆典错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆