Skip to content
Related Articles

Related Articles

How to configure node.js console font ?
  • Difficulty Level : Expert
  • Last Updated : 27 Feb, 2020

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 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 widely used and popular module for formatting the text.
  • Users can format the console text very easily.

Installing Chalk module and using It:

  • You can visit the link Install Chalk module to install this package using command.
    $ npm install --save chalk
  • After installing chalk module you can check your chalk version on 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 command.
    $ node app.js
  • Requiring module: You need to include the chalk module in your file using these lines.
    var chalk = require('chalk');
  • Filename: app.js




    // Include chalk module
    var 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:

  • The project structure will look like this:
    project structure
  • Run app.js file using following commands:
    node app.js

    Output of above command

My Personal Notes arrow_drop_up
Recommended Articles
Page :