Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a scrollable/rewritable terminal/stdout interface with Node.js

When I print to my terminal in Node.js, I use console.log to output a new line of text. However, there are some applications that dynamically update the same lines of console output, instead of just adding new ones. A popular example of this is the ASCII loading bar that appears in wget or scp.

There are some applications that fill the entire terminal window with dynamic output. ngrok is an example of this:

ngrok

This application updates the information above dynamically.

Are there frameworks that will help me create a similar dynamic output in Node.js? Does this have a name?

like image 436
drewblaisdell Avatar asked Oct 22 '25 18:10

drewblaisdell


2 Answers

Well maybe this is too much for what you need.. but I'm going to give you some options of tools that you can use..

A better option to just use a console.log It would be using colors instead:

  • https://www.npmjs.com/package/color
  • https://www.npmjs.com/package/chalk

If you need prompt questions to the user:

  • https://www.npmjs.com/package/inquirer

For create command lines, you have:

  • https://www.npmjs.com/package/commander

For terminal interfaces you have these:

  • https://github.com/chjj/blessed

    Then on the top of that one you have this one:

  • https://github.com/Yomguithereal/react-blessed

Those are amazing tools.. I'm using them for my project and they just rock. There are some others.. tell if you need more hehe

like image 143
bySamo Avatar answered Oct 24 '25 07:10

bySamo


You can try this module: ansi.js

like image 25
micnic Avatar answered Oct 24 '25 09:10

micnic



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!