Color Coding the Output

Learn how to differentiate between the types of messages being displayed to the user, using the npm colors package.

Using the colors package

When you log your output, it can be useful to distinguish what type of message is displayed to the user. You can do this using the npm colors package, which allows you to give your output a different color based on the type of message you are displaying. For example:

  • If something goes wrong, you will use red.
  • If something goes right, you will use green.
  • If the user needs to be warned about something, you will use yellow.

Go ahead and give it a try.

Get hands-on with 1400+ tech skills courses.