From a node.js tutorial, I see those two process.stdout functions :
process.stdout.clearLine(); process.stdout.cursorTo(0);
But I'm using a more recent node.js version (4.2.4), and those functions do not exist. I get process.stdout.clearLine is not a function
and process.stdout.cursorTo is not a function
.
What is the equivalent of clearLine and cursorTo on node.js version 4.2.4 ?
EDIT :
Those are not working either :
process.readline.clearLine(); process.readline.cursorTo(0); function writeWaitingPercent(p) { process.readline.clearLine(); process.readline.cursorTo(0); process.stdout.write(`waiting ... ${p}%`); }
I get Cannot read property 'clearLine' of undefined
This is the solution :
First, require readline :
var readline = require('readline');
Then, use cursorTo like this :
function writeWaitingPercent(p) { //readline.clearLine(process.stdout); readline.cursorTo(process.stdout, 0); process.stdout.write(`waiting ... ${p}%`); }
I've commented clearLine, since it's useless in my case (cursorTo move back the cursor to the start)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With