title: Nodejs child_process spawn custom stdio
body: <p>I would like to use custom stream to handle child_process.spawn stdio.</p>
  
  <p>For example</p>
  
  <pre><code>const cp = require('child_process');
  const process = require('process');
  const stream = require('stream');
  
  var customStream = new stream.Stream();
  customStream.on('data', function (chunk) {
      console.log(chunk);
  });
  
  cp.spawn('ls', [], {
      stdio: [null, customStream, process.stderr]
  });
  </code></pre>
  
  <p>I get error <code>Incorrect value for stdio stream</code>.</p>
  
  <p>There is documentation for child_process.spawn <a href="https://nodejs.org/api/child_process.html#child_process_options_stdio" rel="noreferrer">https://nodejs.org/api/child_process.html#child_process_options_stdio</a>. It says for stdio options that it can take Stream object</p>
  
  <blockquote>
    <p>Stream object - Share a readable or writable stream that refers to a tty, file, socket, or a pipe with the child process.</p>
  </blockquote>
  
  <p>I guess I'am missing this "refers to" part.</p>