Hi Guest 1 HomePage 1 Jobs 1 WalkIn 1Articles  

 :) Latest Topic
Node.js Tutorial
Parts of Node.js
Features of Node.js
Install Node.js Windows
Install Node.js Linux
Node.js First Example
Node.js Console
Node.js REPL
Node.js NPM
Node.js CL Options1
Node.js CL Option2
Node.js Globals
Node.js OS
Node.js Timer
Node.js Errors
Node.js DNS
Node.js Net
Node.js Crypto
Node.js TLS/SSL
Node.js Debugger
Node.js Process
Node.js Process Example
Node.js Process Example2
Node.js Child Process
Child Process EXEC
Child Process SPAWN
Child Process Fork
Node.js Buffers
Node.js Streams
Node.js Reading Stream
Node.js Writing Stream
Node.js Piping Stream
Node.js Chaining Streams
Node.js File System Part1
Node.js File System Part2
Node.js File System Part3
Node.js Path
Node.js StringDecoder
Node.js Query String
Node.js ZLIB
Node.js Assertion
Node.js V8
Node.js Callbacks
Node.js Events
Node.js Punycode
Node.js TTY
Node.js Web Module
Node.js Upload Files
Node.js Email Send
Node.js BuiltIn Modules
Node.js Assert Code
Node.js Assert Function
 


  

 
Node.js Console
Question Posted on 27 Jan 2024

Home >> Tutorial >> Node.js Tutorial >> Node.js Console


Node.js Console

Node.js Console



When we say about the Node.js console, this module will provides a simple debugging console same as JavaScript console mechanism provided by web browsers.

And below are the three console methods which are used to write any node.js stream:-

(1)console.log()
(2)console.error()
(3)console.warn()

(1)Node.js console/log()



We use console.log() function to display simple message on console.

File: console_example.js


console.log('Hello CrackYourInterview');


Now you need to open Node.js command prompt and run the following code to call console_example.js file.


node console_example.js




output brower nodejs/>

We can also use format specifier in console.log() function and below is the function and the filename.

File: console_example1.js

console.log('Hello %s','CrackYourInterview');

Now need to open Node.js command prompt and neew to run the below command to execute the file console_example1.js:-

node console_example1.js



SpecifierConsole


(2)Node.js console.error()



Well console.error() function is mainly used to rendor error message on the console.

File: console_example2.js

console.error(new Error('Hi! this is wrong method'));

Now you will open Node.js command prompt and run the follwoing code:

node console_example2.js



Error Console


(3)Node.js console.warn()



Well console.warn() function is mainly used to display warning message on the console.

File: console_example3.js

const name ='Pau';
console.warn('You are not doing well $(name)! so correct your input!');


Now you need to open Node.js command prompt and run the below code:-

node console_example3.js



Error Console





Other Important Questions
Parts of Node.js
Install Node.js Linux
Node.js First Example
Node.js Globals
Node.js DNS







 
Top Searches:asp net questions vb net questions sql query uddl questions class javascript Questions sharepoint interview questions and concept silverlight questions and concept wcf questions beans general knowledge ajax questions
PHP | Biztalk | Testing | SAP | HR |