title: communicating with a spawn() child process?
body: <p>I'm trying to create a child process using <code>spawn()</code> with it's own terminal</p>
  <p>parent.js:</p>
  <pre><code>const spawn = require('child_process').spawn;
  
  console.log('started parent process...'); //this should be printed in the parent terminal
  
  const child = spawn('start node', [`child.js`], {
      cwd:__dirname,
      shell: true,
      stdio: [null, null, null, 'pipe']
  });
  
  const Name = 'general kenobi';
  
  child.stdio[3].write(Name);
  
  child.stdio[3].on('data', (data) =&gt; {
      console.log('data=&gt;', data.toString());
      child.kill();
  });
  </code></pre>
  <p>child.js:</p>
  <pre><code>console.log('started child process...');
  
  (async()=&gt;{
      await new Promise(r=&gt;setTimeout(r,3000));
  
      try{
          let net = require('net');
          let pipe = new net.Socket({ fd: 3 });
  
          pipe.on('data',(data)=&gt;{
              pipe.write(`hello there ${data}`);
          });
      }catch(err){console.log(err)}
      await new Promise(r =&gt; setTimeout(r, 3000));
  })();
  </code></pre>
  <p>the expected data should be <code>data=&gt; hello there general kenobi</code> but it gives this error in the child terminal</p>
  <blockquote>
  <pre><code> throw new ERR_INVALID_FD_TYPE(type);
    ^
  
  TypeError [ERR_INVALID_FD_TYPE]: Unsupported fd type: UNKNOWN
      at new NodeError (node:internal/errors:371:5)
      at createHandle (node:net:152:9)
      at new Socket (node:net:340:20)
      at Object.&lt;anonymous&gt; (C:\...\parent.js:4:12)
      at Module._compile (node:internal/modules/cjs/loader:1101:14)
      at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
      at Module.load (node:internal/modules/cjs/loader:981:32)
      at Function.Module._load (node:internal/modules/cjs/loader:822:12)
      at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
      at node:internal/main/run_main_module:17:47 {
    code: 'ERR_INVALID_FD_TYPE'
  }
  </code></pre>
  </blockquote>
  <p>I couldn't find many references so I used <a href="https://www.youtube.com/watch?v=9o8B3L0-d9c" rel="noreferrer">this video</a> as a guide</p>
  <p>(please try to avoid a 3rd party package while answering)</p>