How can I add color to my Node.js console logs?

Question

Grade: Education Subject: Support
How can I add color to my Node.js console logs?
Asked by:
47 Viewed 47 Answers

Answer (47)

Best Answer
(351)
You can use ANSI escape codes to add color to your Node.js console logs. These codes are sequences of characters that tell the terminal to change the text color, style, or background. Libraries like `chalk` simplify this process by providing a more user-friendly API. For example, `console.log(chalk.green('Success!'))` will print 'Success!' in green.