Created
March 5, 2021 14:33
-
-
Save MahefaAbel/66d01b1000553dc7df876023de35f092 to your computer and use it in GitHub Desktop.
Clear / reset Console for Node.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Node.js — Clear/reset Terminal / Console. | |
# Method 1 (My favorite) | |
process.stdout.write('\x1Bc'); | |
# Method 2 | |
console.clear(); | |
# Method 3 | |
const readline = require('readline') | |
const blank = '\n'.repeat(process.stdout.rows) | |
console.log(blank) | |
readline.cursorTo(process.stdout, 0, 0) | |
readline.clearScreenDown(process.stdout) | |
# Method 4 | |
process.stdout.write('\033c'); | |
# Method 5 | |
console.log('\x1Bc'); | |
process.stdout.write('\x1B[2J\x1B[0f\u001b[0;0H'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment