Node.Js on windows – How to clear console

Node.Js on windows – How to clear console

console.log(33[2J);

This works on linux. Not sure about windows.

You can trick the user using something like this:

var lines = process.stdout.getWindowSize()[1];
for(var i = 0; i < lines; i++) {
    console.log(rn);
}
process.stdout.write(33c);

This also works on windows. Win7 at least.

Node.Js on windows – How to clear console

This clears the console on Windows and puts the cursor at 0,0:

var util = require(util);
util.print(u001b[2Ju001b[0;0H);

or

process.stdout.write(u001b[2Ju001b[0;0H);

Leave a Reply

Your email address will not be published.