title: Can't seem to figure out how to get the output of an process fired with spawn. stdout.on('data') not outputting for me
body: <p>I am trying to setup some automation on a <a href="https://developer.valvesoftware.com/wiki/Rust_Dedicated_Server" rel="nofollow noreferrer">game server</a> for the game <a href="https://store.steampowered.com/app/252490/Rust/" rel="nofollow noreferrer">Rust</a>.
  The game server itself is ran by running its executable file RustDedicated.exe <a href="https://developer.valvesoftware.com/wiki/Rust_Dedicated_Server#Configuration_.26_running" rel="nofollow noreferrer">with some arguments.</a></p>
  <p>According to some googling and reading here on Stack Overflow I have made this script:</p>
  <pre><code>import config from &quot;config&quot;;
  import { ChildProcessWithoutNullStreams, spawn } from &quot;child_process&quot;;
  
  const GAMESERVERPATH: string =  config.get(&quot;Environment.RustDedicatedPath&quot;);
  const EXECUTABLE: string =      config.get(&quot;Environment.ExecutableFile&quot;);
  const GAMESERVERARGS: Array&lt;string&gt; = [
      &quot;-batchmode&quot;,
      &quot;+server.port&quot;,         `${config.get(&quot;Server.port&quot;)}`,
      &quot;+server.level&quot;,        `&quot;${config.get(&quot;Server.level&quot;)}&quot;`,
      &quot;+server.seed&quot;,         `${config.get(&quot;Server.seed&quot;)}`,
      &quot;+server.worldsize&quot;,    `${config.get(&quot;Server.worldsize&quot;)}`,
      &quot;+server.maxplayers&quot;,   `${config.get(&quot;Server.maxplayers&quot;)}`,
      &quot;+server.hostname&quot;,     `&quot;${config.get(&quot;Server.hostname&quot;)}&quot;`,
      &quot;+server.description&quot;,  `&quot;${config.get(&quot;Server.description&quot;)}&quot;`,
      &quot;+server.headerimage&quot;,  `&quot;${config.get(&quot;Server.headerimage&quot;)}&quot;`,
      &quot;+rcon.port&quot;,           `${config.get(&quot;Rcon.port&quot;)}`,
      &quot;+rcon.password&quot;,       `&quot;${config.get(&quot;Rcon.password&quot;)}&quot;`,
      &quot;+rcon.web&quot;,            `${config.get(&quot;Rcon.web&quot;)}`
  ];
  
  const gameServerProc : ChildProcessWithoutNullStreams = spawn(
      GAMESERVERPATH+EXECUTABLE,
      GAMESERVERARGS,
      {
          cwd:            GAMESERVERPATH,
          shell:          true,
      }
  );
  
  gameServerProc.stdout.on(&quot;data&quot;, (data) =&gt; {
      console.log(`stdout:${data.toString()}`);
  });
  gameServerProc.stderr.on(&quot;data&quot;, (data) =&gt; {
      console.log(`stderr:${data.toString()}`);
  });
  gameServerProc.on(&quot;error&quot;, (err) =&gt; {
      console.log(`error:${err.message}`);
  });
  </code></pre>
  <p>What is happening is that i can see the output of the executable in the terminal window, and the server is firing without errors, but it seems that stdout is not firing the on('data') event.
  I never see <code>stdout:</code>.</p>
  <p>See the screenshot below where i have Code open, the output is on the bottom right.
  <img src="https://i.imgur.com/fAvmNMF.png" alt="Dump of Code" /></p>
  <p>Why is my script failing to get the on('data') firing when the executable outputs?</p>