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
process.stdout.write('\033c');
This also works on windows. Win7 at least.
Haven't tested this on Windows but works on unix. The trick is in the child_process
module. Check the documentation. You can save this code as a file and load it to the REPL every time you need it.
var util = require('util');
var exec = require('child_process').exec;
function clear(){
exec('clear', function(error, stdout, stderr){
util.puts(stdout);
});
}
This is for Linux mainly but is also reported to work in Windows.
There is Ctrl + L in Gnome Terminal that clears the terminal as such. It can be used with Python, Node JS or any Interpreter presumably that uses terminal. I tend to clear many times hence this is very handy. Instaed of doing clear in Gnome Terminal you can just do Ctrl + L, it has nothing to do with the REPL running.
If you're using VSCode
you can use CTRL + K
. I know this is not a generic solution but may help some people.
Just use CTRL + L
on windows to clear the console.
And to clear the console while in strict mode on Windows:
'use strict';
process.stdout.write('\x1Bc');