Setting Up Your First Node.js Application Step-by-Step

Software Engineer | Passionate about Web Development, DSA & Problem Solving. I write simple, practical tech blogs to help developers learn and grow. Exploring JavaScript, C++, Backend & Modern Web Technologies.
Introduction
Every modern web application depends on a backend system that can handle requests, process data, and communicate efficiently with databases and external services. Over the years, Node.js has become one of the most popular technologies for backend development because of its speed, simplicity, and JavaScript-based ecosystem. From startups building APIs to large-scale companies handling millions of requests, Node.js powers a massive portion of today’s internet.
For beginners entering backend development, setting up the first Node.js application is an important milestone. It introduces the workflow of server-side JavaScript execution, terminal-based development, and application runtime management. Unlike frontend JavaScript that runs inside the browser, Node.js executes JavaScript directly on the system using the V8 engine, enabling developers to build servers, automation tools, and scalable applications.
Understanding how to install Node.js, verify the setup, use the Node REPL, create JavaScript files, and run a simple server builds the foundation for all future Node.js development. These are also common interview and practical development topics that every backend developer should know clearly.
In this blog, we will go step by step through setting up your first Node.js application in a beginner-friendly and professional manner.
Installing Node.js
Before writing any Node.js application, Node.js must be installed on the system.
Node.js includes:
The Node runtime
npm (Node Package Manager)
npm helps install external packages and libraries.
Installation Steps
Visit the official Node.js website
Download the LTS (Long-Term Support) version
Run the installer
Complete installation using default settings
The process is almost identical across Windows, macOS, and Linux.
Real-World Analogy
Think of Node.js like installing a JavaScript engine outside the browser:
Browser runs JavaScript for frontend
Node.js runs JavaScript on your computer/server
Checking Installation Using Terminal
After installation, it is important to verify that Node.js and npm are properly installed.
This is done using terminal or command prompt commands.
Example
node -v
npm -v
Explanation :
node -vshows installed Node.js versionnpm -vshows installed npm versionIf version numbers appear, installation was successful
Example Output:
v22.0.0
10.5.1
Understanding Node REPL
REPL stands for:
Read
Evaluate
Print
Loop
It is an interactive environment where JavaScript code can be executed line by line directly in the terminal.
REPL is useful for:
Quick testing
Learning JavaScript
Debugging small snippets
Example
node
After entering:
> 5 + 5
10
Explanation :
Typing
nodestarts the REPL environmentJavaScript expressions can be executed instantly
Node reads input, evaluates it, prints output, and waits again
Real-World Analogy
REPL is like a calculator for JavaScript:
Type expression
Instantly see result
Continue experimenting interactively
Creating Your First JavaScript File
After understanding REPL, the next step is creating a JavaScript file.
Node.js applications are usually written in .js files.
Example
Create a file named:
app.js
Inside the file:
console.log("Hello Node.js");
Explanation :
console.log()prints output to terminalapp.jsacts as the main application fileThis is the first executable Node.js script
Project Structure Example
project/
│
├── app.js
Running Script Using Node Command
Node.js executes JavaScript files using the node command.
Example
node app.js
Explanation :
nodestarts the Node runtimeapp.jsis passed to runtimeNode reads and executes the file
Output:
Hello Node.js
Script Execution Flow
Node runtime starts
JavaScript file loaded
Code executed
Output displayed
Writing Your First Hello World Server
One of the biggest advantages of Node.js is creating servers using JavaScript.
Node provides a built-in http module for handling HTTP requests.
Example
const http = require('http');
const server = http.createServer((req, res) => {
res.end("Hello World Server");
});
server.listen(3000, () => {
console.log("Server running on port 3000");
});
Explanation :
require('http')imports Node’s HTTP modulecreateServer()creates a web serverreqrepresents client requestresrepresents server responselisten(3000)starts server on port 3000
When visiting:
http://localhost:3000
Browser displays:
Hello World Server
Request-Response Lifecycle
Browser sends request
Node server receives request
Response sent back to browser
Understanding Node Execution Flow
Understanding execution flow helps beginners visualize how Node.js works internally.
Execution Steps
User runs
node app.jsNode runtime loads V8 engine
JavaScript code compiled
Code executed
Output generated
Example
console.log("Step 1");
console.log("Step 2");
console.log("Step 3");
Explanation :
Node executes code sequentially
Each statement runs line by line
Output appears in same order
Output:
Step 1
Step 2
Step 3
Conclusion
Setting up your first Node.js application is the starting point of backend development with JavaScript. By learning how to install Node.js, verify the environment, use the REPL, create JavaScript files, and execute scripts, developers gain a foundational understanding of how server-side JavaScript works.
We also explored how Node.js executes code using its runtime environment and built a simple Hello World server using the built-in HTTP module. These concepts may seem simple initially, but they form the backbone of all advanced Node.js applications, including APIs, real-time systems, and scalable backend architectures.
The key takeaway is that Node.js is more than just a runtime—it is a complete environment for building modern backend applications using JavaScript. Mastering these basics ensures a smoother transition into advanced topics such as Express.js, databases, authentication, and asynchronous programming.
For beginners, this first setup is not just about running code—it is the first step toward becoming a backend developer.



