The console is a module pretty similar to the Console provided by the most of the browser for the debugging purpose. It helps developers to debug their application easily by printing the message on the system console. You can use this using one of the following methods.
- A Console class which provides methods such as console.log(), console.error() and console.warn()
- A global console instance configured to write to process.stdout and process.stderr.
#1. Using Console Class
The Node.js Console class provides the following methods
> console.log('Hello World!'); Output=> Hello World!
> console.error(new Error('Missing requied parameters')); Output=> [Error: Missing requied parameters]
> const name = 'TecAdmin';
> console.warn(Sorry ${name}!
);
Output=> Sorry TecAdmin!