Getting Started with NodeJS
Last Updated :
23 Jul, 2025
Node.js is an open-source, cross-platform JavaScript runtime environment that executes JavaScript code outside of a browser. It is built on Chrome's V8 JavaScript engine. It is also event-driven means it can handle multiple requests at the same time without blocking. By using Node.js, we can create a web application, real-time applications, APIs, Command-line tools and many more. It allows you to use JavaScript to write command line tools, creation of dynamic web pages, and many more.
Prerequisites
Basics of Node.js
Core Modules
Node.js provides a set of built-in modules that offer essential functionalities. Some commonly used core modules include:
- HTTP: It is used for creating HTTP servers and clients.
- HTTPS: It is used for creating HTTPS servers and clients.
- FS (File System): It is used for interacting with the file system.
- Path: It is used for handling and transforming file paths.
- Events: It is used for implementing event-driven programming.
- OS: It is used for interacting with the operating system.
Datatypes
Node.js provides a same Datatypes as JavaScript.
- Primitive Datatype Types: It includes datatype such as numbers, strings, Booleans, null, and undefined.
- Objects: It includes datatype such as arrays, functions, dates, regular expressions, and objects.
Objects and Functions
Node.js provides a same Concept of Object and Function as JavaScript.
- Objects: It is used to store data in key-value pairs. The keys are strings and the values can be any type of data, including other objects, arrays, and functions.
- Functions: It is used to used to perform actions in Node.js. It can take arguments and return values.
Buffer
It is a temporary storage areas in memory used for handling binary data directly in Node.js. It is a instances of the Buffer class, which is a global object in Node.js. It is particularly useful for handling binary data such as reading from or writing to files or network sockets.
Example:
// Create a new buffer of 20 bytes
const buffer = Buffer.alloc(10);
// Write the string "GeeksForGeeks" to the buffer
buffer.write("GeeksForGeeks");
// Convert the buffer to a string
const string = buffer.toString();
// Print the string to the console
console.log(string);
Streams
It is a objects in Node.js and it is used to handle large amounts of data efficiently. It allow you to read from or write to data sources incrementally rather than loading the entire data set into memory at once. It is implemented using EventEmitter.
package.json
package.json file is a manifest for Node.js projects. It contains metadata about the project such as its name, version, dependencies, and scripts. This file is essential for managing project dependencies, defining project settings and automating tasks using npm (Node Package Manager).
CLI Tools
Node.js provides various command-line interface (CLI) tools for development and project management:
- npm (Node Package Manager): It is used for installing, managing, and publishing Node.js packages.
- npx: It is used to executing Node.js packages directly from the npm registry without installing them globally. (It mainly used when creating React.js, Next.js Application).
- REPL (Read Eval Print Loop): It is a Interactive console for experimenting with Node.js code snippets.
Steps to create Node Application
Step 1: Create a a folder for your application and move to that folder using below command.
cd foldername
Step 2: Create a NodeJS application using the following command:
npm init
Step 3: install express and ejs module by using the following command:
npm install express ejs
The updated dependency in pakage.json will look like this:
"dependencies": {
"ejs": "^3.1.10",
"express": "^4.19.2"
}
Project Structure:

Example: The below example demonstrate the use of express and ejs module.
HTML
<!-- File path: /views/index.ejs -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1.0">
<title>Node.js and EJS Example</title>
</head>
<body>
<h1>Message from Server:</h1>
<h2 style="color: green;"><%= data.message %></h2>
</body>
</html>
JavaScript
//File path: /index.js
// Import required modules
const express = require('express');
// Port on which the server will run
const ejs = require('ejs');
// Create an Express application
const app = express();
const port = 3000;
// Set EJS as the view engine
app.set('view engine', 'ejs');
// Define a route
app.get('/', (req, res) => {
// Sample data to pass to the EJS template
const data = {
message: 'Hello from, GeeksForGeeks!',
};
// Render the EJS template and pass the data
res.render('index', { data });
});
// Start the server
app.listen(port, () => {
console.log(`Server is listening at http://localhost:${port}`);
});
To run the application use the following command:
node index.js
Output: Now go to http://localhost:3000 in your browser.

Features of Node.js
- It is asynchronous and event-driven means it can handle multiple requests at the same time without blocking.
- It is uses single-threaded event loop to handle requests asynchronously.
- It is a is cross-platform compatible means it can run on Windows, macOS, and Linux.
- It has a package manager called NPM by using it, you can easily install and manage third party modules.
- It has a very large community means there are many resources available to learn and use Node.js.
How to use Nodejs in a Project?
To use Node.js in a project, First you need to install it on your system from a official website of a Node.js. After installing it you can initialize a project by using npm init command and answering some few questions.
Once you have initialized your project, you can create a necessary files and if you want to use any external dependencies(module) then you can install it by using npm install module_name command. You can run the project with by using node index.js command.
Similar Reads
Node.js Tutorial Node.js is a powerful, open-source, and cross-platform JavaScript runtime environment built on Chrome's V8 engine. It allows you to run JavaScript code outside the browser, making it ideal for building scalable server-side and networking applications.JavaScript was mainly used for frontend developme
4 min read
Introduction & Installation
NodeJS IntroductionNodeJS is a runtime environment for executing JavaScript outside the browser, built on the V8 JavaScript engine. It enables server-side development, supports asynchronous, event-driven programming, and efficiently handles scalable network applications. NodejsNodeJS is single-threaded, utilizing an e
5 min read
Node.js Roadmap: A Complete GuideNode.js has become one of the most popular technologies for building modern web applications. It allows developers to use JavaScript on the server side, making it easy to create fast, scalable, and efficient applications. Whether you want to build APIs, real-time applications, or full-stack web apps
6 min read
How to Install Node.js on LinuxInstalling Node.js on a Linux-based operating system can vary slightly depending on your distribution. This guide will walk you through various methods to install Node.js and npm (Node Package Manager) on Linux, whether using Ubuntu, Debian, or other distributions.PrerequisitesA Linux System: such a
6 min read
How to Install Node.js on WindowsInstalling Node.js on Windows is a straightforward process, but it's essential to follow the right steps to ensure smooth setup and proper functioning of Node Package Manager (NPM), which is crucial for managing dependencies and packages. This guide will walk you through the official site, NVM, Wind
6 min read
How to Install NodeJS on MacOSNode.js is a popular JavaScript runtime used for building server-side applications. Itâs cross-platform and works seamlessly on macOS, Windows, and Linux systems. In this article, we'll guide you through the process of installing Node.js on your macOS system.What is Node.jsNode.js is an open-source,
6 min read
Node.js vs Browser - Top Differences That Every Developer Should KnowNode.js and Web browsers are two different but interrelated technologies in web development. JavaScript is executed in both the environment, node.js, and browser but for different use cases. Since JavaScript is the common Programming language in both, it is a huge advantage for developers to code bo
6 min read
NodeJS REPL (READ, EVAL, PRINT, LOOP)NodeJS REPL (Read-Eval-Print Loop) is an interactive shell that allows you to execute JavaScript code line-by-line and see immediate results. This tool is extremely useful for quick testing, debugging, and learning, providing a sandbox where you can experiment with JavaScript code in a NodeJS enviro
4 min read
Explain V8 engine in Node.jsThe V8 engine is one of the core components of Node.js, and understanding its role and how it works can significantly improve your understanding of how Node.js executes JavaScript code. In this article, we will discuss the V8 engineâs importance and its working in the context of Node.js.What is a V8
7 min read
Node.js Web Application ArchitectureNode.js is a JavaScript-based platform mainly used to create I/O-intensive web applications such as chat apps, multimedia streaming sites, etc. It is built on Google Chromeâs V8 JavaScript engine. Web ApplicationsA web application is software that runs on a server and is rendered by a client browser
3 min read
NodeJS Event LoopThe event loop in Node.js is a mechanism that allows asynchronous tasks to be handled efficiently without blocking the execution of other operations. It:Executes JavaScript synchronously first and then processes asynchronous operations.Delegates heavy tasks like I/O operations, timers, and network r
5 min read
Node.js Modules , Buffer & Streams
NodeJS ModulesIn NodeJS, modules play an important role in organizing, structuring, and reusing code efficiently. A module is a self-contained block of code that can be exported and imported into different parts of an application. This modular approach helps developers manage large projects, making them more scal
5 min read
What are Buffers in Node.js ?Buffers are an essential concept in Node.js, especially when working with binary data streams such as files, network protocols, or image processing. Unlike JavaScript, which is typically used to handle text-based data, Node.js provides buffers to manage raw binary data. This article delves into what
4 min read
Node.js StreamsNode.js streams are a key part of handling I/O operations efficiently. They provide a way to read or write data continuously, allowing for efficient data processing, manipulation, and transfer.\Node.js StreamsThe stream module in Node.js provides an abstraction for working with streaming data. Strea
4 min read
Node.js Asynchronous Programming
Node.js NPM
Node.js Deployments & Communication
Node DebuggingDebugging is an essential part of software development that helps developers identify and fix errors. This ensures that the application runs smoothly without causing errors. NodeJS is a JavaScript runtime environment that provides various debugging tools for troubleshooting the application.They help
2 min read
How to Perform Testing in Node.js ?Testing is a method to check whether the functionality of an application is the same as expected or not. It helps to ensure that the output is the same as the required output. How Testing can be done in Node.js? There are various methods by which tasting can be done in Node.js, but one of the simple
2 min read
Unit Testing of Node.js ApplicationNode.js is a widely used javascript library based on Chrome's V8 JavaScript engine for developing server-side applications in web development. Unit Testing is a software testing method where individual units/components are tested in isolation. A unit can be described as the smallest testable part of
5 min read
NODE_ENV Variables and How to Use Them ?Introduction: NODE_ENV variables are environment variables that are made popularized by the express framework. The value of this type of variable can be set dynamically depending on the environment(i.e., development/production) the program is running on. The NODE_ENV works like a flag which indicate
2 min read
Difference Between Development and Production in Node.jsIn this article, we will explore the key differences between development and production environments in Node.js. Understanding these differences is crucial for deploying and managing Node.js applications effectively. IntroductionNode.js applications can behave differently depending on whether they a
3 min read
Best Security Practices in Node.jsThe security of an application is extremely important when we build a highly scalable and big project. So in this article, we are going to discuss some of the best practices that we need to follow in Node.js projects so that there are no security issues at a later point of time. In this article, we
4 min read
Deploying Node.js ApplicationsDeploying a NodeJS application can be a smooth process with the right tools and strategies. This article will guide you through the basics of deploying NodeJS applications.To show how to deploy a NodeJS app, we are first going to create a sample application for a better understanding of the process.
5 min read
How to Build a Microservices Architecture with NodeJSMicroservices architecture allows us to break down complex applications into smaller, independently deployable services. Node.js, with its non-blocking I/O and event-driven nature, is an excellent choice for building microservices. How to Build a Microservices Architecture with NodeJS?Microservices
3 min read
Node.js with WebAssemblyWebAssembly, often abbreviated as Wasm, is a cutting-edge technology that offers a high-performance assembly-like language capable of being compiled from various programming languages such as C/C++, Rust, and AssemblyScript. This technology is widely supported by major browsers including Chrome, Fir
3 min read
Resources & Tools
Node.js Web ServerA NodeJS web server is a server built using NodeJS to handle HTTP requests and responses. Unlike traditional web servers like Apache or Nginx, which are primarily designed to give static content, NodeJS web servers can handle both static and dynamic content while supporting real-time communication.
6 min read
Node Exercises, Practice Questions and SolutionsNode Exercise: Explore interactive quizzes, track progress, and enhance coding skills with our engaging portal. Ideal for beginners and experienced developers, Level up your Node proficiency at your own pace. Start coding now! #content-iframe { width: 100%; height: 500px;} @media (max-width: 768px)
4 min read
Node.js ProjectsNode.js is one of the most popular JavaScript runtime environments widely used in the software industry for projects in different domains like web applications, real-time chat applications, RESTful APIs, microservices, and more due to its high performance, scalability, non-blocking I/O, and many oth
9 min read
NodeJS Interview Questions and AnswersNodeJS is one of the most popular runtime environments, known for its efficiency, scalability, and ability to handle asynchronous operations. It is built on Chromeâs V8 JavaScript engine for executing JavaScript code outside of a browser. It is extensively used by top companies such as LinkedIn, Net
15+ min read