Node.Js on windows – How to clear console

console.log('\033[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('\r\n');
}

Leave a Comment