Coloring console logs in nodejs

Colored console log messages can be helpful in determining the progress of the application when we boot it. Since the application will be started from the console, displaying green for the infos, Red for the error will be helpful in diagnosing on which stage the application has failed.

I use SindreSorhus's chalk because it is simple, doesn't extend String.prototype and used by ~4500 other modules.

Let's get to the code. First, we need to install chalk.

To demonstrate red, we are going to print stack trace of an error.


For my new posts, Subscribe via weekly RSS, common RSS or Subscribe via Email