将stdoutconfiguration到node.js中另一个进程的stdin

我是node.js的新手,并试图在一行中执行两个进程,第一个进程的stdout传送到第二个stdin。 然后第二个进程的stdout应该作为对URL请求的响应传递给variablesres。 代码在这里。 其中一部分是由别人写的,所以也许我有误解:

var sox = spawn("sox", soxArgs) var rubberband = spawn("rubberband", rubberbandArgs) sox.stdout.pipe(rubberband.stdin) rubberband.stdout.pipe(res) #won't send to res anything, why? #rubberband.stdin.pipe(res) won't send to res anything, either! #sox.stdout.pipe(res) will work just fine sox.stdin.write(data) sox.stdin.end() #the actual sox process will not execute until sox.stdin is filled with data..? 

任何帮助,将不胜感激! 我花了几个小时看着这个!

我认为你正在寻找的解决scheme是从标准输出到标准输出从https://nodejs.org/api/process.html#process_process_stdin

 process.stdin.on('readable', () => { const chunk = process.stdin.read(); if (chunk !== null) { process.stdout.write(`data: ${chunk}`); } }); process.stdin.on('end', () => { process.stdout.write('end'); });