1

Sometimes we need to show different command lines out of different colors. Here is a solution which I found, which can helpful for other developers too.

Santosh Kori
  • 461
  • 4
  • 12
  • ... and if you want different colors for messages generated via npm scripts - refer to [this answer](https://stackoverflow.com/questions/50226385/apply-visual-styling-to-echo-commands-used-in-npm-scripts-via-package-json/50275198#50275198). – RobC Jul 05 '20 at 08:48

2 Answers2

0

First, install it to the directory you'd like to work in.

npm install colors

Now open up a little test script for yourself, and try something like this:

const colors = require('colors');

const string1 = 'This string is red.'.red;
const string2 = 'This string is blue.'.blue;

console.log(string1);
console.log(stringThree);
Santosh Kori
  • 461
  • 4
  • 12
0

npm chalk is another popular library

const chalk = require('chalk');

console.log(chalk.green('Hello world!'));

All you have to do is npm install chalk and you are all set. This is the link for more information.

technoY2K
  • 2,442
  • 1
  • 24
  • 38