NPM Chalk library in nodeJs is used for styling the format of text and it allows us to customize our own themes in our nodeJs projects. We can customize the color of the command_line output using Chalk. When i was making my quiz projects using javascript , Chalk NPM library was really useful to me as i set the color of message for the right answer to green and red for the wrong one. This is how using Chalk NPM library in my projects made them look good and attractive.
If we want to use chalk in our Javascript projects ,
we need to import Chalk npm library first by using the following
code snippet.
const chalk = require('chalk');
console.log(chalk.color_name("Hello,world!"));
We can also add more styles to our customized text , like we can make the text bold by using .bold before the color name is mentioned and we will get a bold and coloured text. Here is the code snippet. console.log(chalk.bold.color_name("Hello,world!"));