title: How to clear terminal and scroll back in nodejs?
body: <p>I'm using nodemon and want to remove the scroll back whenever it detects a code change.</p>
  <p>I tried <code>console.clear()</code> but this does not clear history.</p>
  <p>What I am trying to do is to send the terminal escape sequence ESC [ 3J - clear screen + history. <a href="https://apple.stackexchange.com/questions/31872/how-do-i-reset-the-scrollback-in-the-terminal-via-a-shell-command">https://apple.stackexchange.com/questions/31872/how-do-i-reset-the-scrollback-in-the-terminal-via-a-shell-command</a></p>
  <p>index.js:</p>
  <pre class="lang-js prettyprint-override"><code>...
  var cmd = '3J';
  const seq = `\x1B\x5B${cmd}`;
  console.dir(seq,{showHidden:true});
  debug(&quot;Cleared?&quot;);
  ...
  </code></pre>
  <p>but the output is:</p>
  <pre><code>[nodemon] starting `node index.js`
    index:index.js Starts +0ms
  '\u001b[3J'
    index:index.js Cleared? +5ms
  </code></pre>