You can format the console font in Node.js using the CHALK module. The chalk module is can be used to customize node console. By using it, one can change the console look using features of it like bold the text, making underlines, highlighting the background color of a text, etc.
Features of Chalk module:
- It’s easy to get started and easy to use.
- It is a widely used and popular module for formatting text.
- Users can format the console text very easily.
Installing the Chalk module and using It:
You can visit the link Install Chalk module to install this package using the command.
$ npm install --save chalk
After installing the chalk module you can check your chalk version on the command prompt by using the following command.
npm version chalk
After that, you can just create a folder and add a file for example app.js. To run this file you need to execute the command.
$ node app.js
Requiring module: You need to include the chalk module in your file using these lines.
var chalk = require('chalk');
Project Structure:

Filename: app.js
javascript
const chalk = require( 'chalk' )
console.log(chalk.black.bgYellow( 'Greetings from Geekforgeeks' ));
console.log(chalk.black.bgBlue( 'Greetings from Geekforgeeks' ));
console.log(chalk.bold.green( 'Greetings from Geekforgeeks' ));
|
Steps to run the program:
Run the app.js file using the following commands:
node app.js
