Gor Gor - 1 year ago 185
Node.js Question

node js terminal color

How can I set terminal font color in node js. I found some modules, but there have limited colors, I want to use any color.

For example.
Something like this.

console.log("text", "#87a213");

On this question`s answer are 3 modules, but in these modules colors are limited. I need to print with any color.

Thank You.

Answer Source

You can use ansi-256-colors package. But it does not support any color. But it supports wide range of colors.

To install:

npm install --save ansi-256-colors

To use:

console.log(colors.fg.getRgb(2,3,4) + colors.bg.getRgb(4,4,4) + 'Hello world!' + colors.reset);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download