Ankaj Gupta
December 25, 2018
Node.js console based example

How To Write and Run Your First Program in Node.js

Step 1: Create a new Node.js file and save named"console_first.js"

 ➤ File Name: console_first.js

console.log('Hello Node.js');

Step 2: Open Command prompt / Node.js command prompt interface, on your computer depends on the operating system. For Windows users : Click on the start button and look for "Command Prompt" or simply write "cmd" in the search field.

tutorials.coderwebsite.com tutorials.coderwebsite.com

Now command prompt is open set your path, Here we have save "console_first.js" file on the desktop.

 ➤ Note: run the following code, For go to desktop

cd desktop

Step 3: After setting the path , run the following code

 ➤ Note: For display output

node console_first.js

This code you can run on the command prompt, as well as Node.js command prompt. You can show below output photos.

a.) Command-prompt output :

tutorials.coderwebsite.com

b.) Node.js command-prompt output :

tutorials.coderwebsite.com

Here you called, console.log() function and display message on console.

Node.js