Node.js console.log - Is it possible to update a line rather than create a new line?

My node.js application has a lot of console logs, which are important for me to see (it's quite a big app so runs for a long time and I need to know that things are still progressing) but I'm ending up with thousands of lines of console logs.

Is it somehow possible to do a console.update that erases/replaces a console line rather than creating a new line?


Try playing with process.stdout methods instead on console:

process.stdout.write("Hello, World");
process.stdout.clearLine(0);
process.stdout.cursorTo(0);
process.stdout.write("\n"); // end the line

TypeScript: clearLine() takes -1, 0, or 1 as a direction parameter with the following meanings:

-1: to the left from cursor.
0: the entire line.
1 - to the right from cursor


Following @michelek's answer, you can use a function somewhat like this:

function printProgress(progress){
    process.stdout.clearLine();
    process.stdout.cursorTo(0);
    process.stdout.write(progress + '%');
}