Search⌘ K
AI Features

Console

Explore the Node.js console module to improve your debugging and logging skills. Understand how to use global console methods like log, error, warn, trace, timers, and table output. Learn to create custom loggers with the Console class for writing outputs beyond the standard console.

Debugging made easy

In this lesson, we shall look at a few different functionalities that this module provides.

The console module that Node.js provides is similar to the JavaScript console that most browsers provide. In case you had not noticed, we were not importing the console module before using console.log. The reason we were not importing anything is that there is a global console instance that is configured to write to process.stdout and process.stderr. Let’s look at some of the options that the global console provides.

Node.js
console.log('Hello World');
console.warn('This is a warning!');
console.error('This is an error');
console.error(new Error('This is a different error'));

You can notice that ...