Today, I am explaining about getting started with NodeJS. Node.js is a powerful JavaScript-based framework/platform built on Google Chrome's JavaScript Engine.
For getting started with Node.js, follow the below steps.
- Download NodeJS from here and Install it.
- Download Git and install it.
- Now, we are checking if the Node.js is installed successfully or not. So, we have made one folder in “D:\” drive, and gave it a name as“NodeJSExamples”. Right-click this folder and go to “Git Bash here”. As shown in the below image.

- It will open one window as shown in the below image.

- Now, type “node” in the opened window as shown in the below image.

- Now, type the below command and hit the Enter key.
console.log("Hello World!");

As you see in the above image, it will give output as “Hello World!”. Now, you can say that your NodeJS is installed successfully.
There are some basic functions that are used in NodeJS.
First, we make a NodeJS file in “D:/NodeJSExamples/” folder and give it a name as “NodeJSBasicFuction.js”. And, write some basic function code and check the output of them.
For running any NodeJS file, open ‘Git Bash’ and type “node filename.js”.
- __Filename
This gives a path to the current executing NodeJS file.
Example - console.log(__filename);
Output - D:\NodeJSExamples\NodeJSBasicFunction.js
![]()
- __dirname
This will give the name of the directory in witch current NodeJS script is executing.
Example - console.log(__filename);
Output - D:\NodeJSExamples
![]()
- Read file
For any file related operation, you have to use ‘fs’ module. The below function is used to read any file.
Example
- var fs=require('fs');
- var data=fs.readFileSync('Exetext.txt');
- console.log(data.toString());
Output
Text file content is start
This articel givve infor about callback in node.js
This is article text line-1
This is article text line-2
This is article text line-3
This is article text line-4
This is article text line-5
This is article text line-6
This is article text line-7
This is article text line-8
Text file content is end
![]()

Manav PandyaPosted Dec 3, 2017, 3:49 AM
Nice share ........