title: How do I color the output of all linux commands in child-process.spawn in nodejs?
body: <p>I want to implement Linux terminal using child-process : spawn of nodejs.
  All behavior is fine, but the following color output problems exist:</p>
  <ol>
  <li><code>require(&quot;child_process&quot;).spawn(mainCommand, subCommmands, {stdio: 'inherit'});</code></li>
  </ol>
  <p>Commands such as <code>npm i</code> and <code>gcc</code> output well in the following code, but Linux commands such as <code>ls -al</code> do not output color. Also, <code>stdout.on, stderr.on</code> via pipe option is not available because <code>{stdio : inherit}</code>.</p>
  <ol start="2">
  <li>so, when I add <code>--color=always</code> to the subCommands parameter and changed option <code>stdio: 'inherit'</code> to <code>stdio: 'pipe'</code>, Linux commands such as <code>ls -al</code> have good color output, but commands such as <code>pip, python3, gcc</code> have the following error with no color:
  <a href="https://i.stack.imgur.com/HkLOk.png" rel="nofollow noreferrer">error: unrecognized command line option ‘--color=always’</a></li>
  </ol>
  <p>Therefore, I would like to implement a Linux terminal that can do all of the following:</p>
  <ol>
  <li>It shall be possible to capture output through child-process. (using stdout.on with <code>stdio:'pipe'</code>)</li>
  <li>Color-preserved output should be produced for all commands (ex: <code>ls</code>, <code>ls -al</code>, <code>npm i</code>, <code>gcc</code>, <code>pip</code>, <code>python</code>, <code>javac</code> etc.).</li>
  </ol>
  <p>Please let me know if you have such a child-process option or chalk option (most of the questions are asked to use chalk or supports color, but there are no specific examples of it).</p>
  <p>My development environment is Ubuntu.</p>
  <p>Please give me some advice, thanks.</p>