The chalk module is can be used to customize node console with colored text. By using it, one can change console look using features of it like bold the text, making underlines, highlighting the background color of a text, etc.
Command to install chalk:
npm install chalk
Coloring console text with chalk.color: Text color can be changed by using the chalk.color method like chalk.black, chalk.red, etc.
const chalk = require( 'chalk' );
console.log(chalk.blue( 'Hello Geek!' ));
console.log(chalk.red( 'This is an Error! ' ));
console.log(chalk.rgb(100, 150, 70)
( 'This is in custom color' ));
|
Output:

Coloring background of console text with chalk.bgcolor: Text background color can be changed by using chalk.bgcolor method like chalk.bgBlack, chalk.bgRed, etc.
const chalk = require( 'chalk' );
console.log(chalk.bgGreen( 'Hello Geek!' ));
console.log(chalk.bgBlackBright( 'This is an Error! ' ));
console.log(chalk.bgWhiteBright( 'This is in custom color' ));
|
Output:

Modifying console text appearance: Text style can be altered by using the methods like chalk.bold, chalk.italic, etc.
const chalk = require( 'chalk' );
console.log( "Text in " , chalk.bold( 'bold' ));
console.log( "Text in " , chalk.dim( 'dim ' ));
console.log( "Text in " , chalk.italic( 'italic' ));
console.log( "Text in " , chalk.underline( 'underline ' ));
|
Output:

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!