Being totally new into node.js environment and philosophy i would like answers to few questions. I had downloaded the node.js for windows installer and also node package man
This code works fine on my node.js server console Windows 7.
process.stdout.write("\u001b[0J\u001b[1J\u001b[2J\u001b[0;0H\u001b[0;0W");
This clears the console on Windows and puts the cursor at 0,0:
var util = require('util');
util.print("\u001b[2J\u001b[0;0H");
or
process.stdout.write("\u001b[2J\u001b[0;0H");
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');
}
i am using a windows CMD and this worked for me
console.clear();
Starting from Node.JS v8.3.0 you can use method clear:
console.clear()
I couldn't get any of the above to work. I'm using nodemon for development and found this the easiest way to clear the console:
console.log("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
It just scrolls the console several lines so you get a clear screen for subsequent console.log commands.
Hope it helps someone.