Open In App

How to configure node.js console font ?

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Share
Report issue
Report

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:

project structure

Filename: app.js 

javascript




// Include chalk module
const chalk = require('chalk')
 
// Set background color to yellow
console.log(chalk.black.bgYellow('Greetings from Geekforgeeks'));
 
// Set background color to blue
console.log(chalk.black.bgBlue('Greetings from Geekforgeeks'));
 
// Modifiers can also be applied
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

Output of above command


Last Updated : 20 Mar, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads