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

You may remember your first successful "Hello World" server. You type a command, press Enter, and suddenly your own server is running on your machine. That moment feels small, but it’s actually the beginning of backend development. Because you would be thinking of server with big CPUs and monitors and all, but you found out your laptop can also be a server.
Node.js is one of the most beginner-friendly ways to enter server-side programming because you can use JavaScript everywhere — both in the browser and on the server.
In this guide, you’ll learn how to:
Install Node.js
Verify the installation
Understand REPL and Node REPL
Create your first JavaScript file
Run Node.js scripts
Build your very first HTTP server
And most importantly, you’ll understand what is happening behind the scenes instead of blindly copying commands.
What is Node.js
Before diving into the guide, we need to know about Node.js. Node.js is a JavaScript runtime built on Google Chrome’s V8 JavaScript engine plus libuv package wrapped with c++ language for handling async task. It allows JavaScript to run outside the browser.
Now JavaScript can do things, which is not possible before like
Creating servers
Reading files
Work with databases
Handle APIs
Build backend applications
Before Node.js, JavaScript mainly lived inside browsers. After Node.js, JavaScript became a full-stack language**.**
Installing Node.js
The official way to install Node.js is from the Node.js website.
Go to - Node.js Official Website
You’ll usually see two versions:
LTS - Long Term Support (recommended for beginners)
Current - Latest features, less stable
Choose LTS because it is more stable and widely used in production.
Checking Installation using Terminal
When you’re done install it, open terminal. Check Node.js version using node -v & NPM version using npm -v , if both shows some version then you’ve successfully installed it otherwise there must be some mistake try again.
What is Node REPL?
Node.js REPL (Read-Eval-Print Loop) is an interactive shell that allows you to execute JavaScript code line by line directly in the Node.js environment. It's bundled with every Node.js installation and provides a quick way to test, debug, or experiment with code without creating a file.
Read: Takes user input, parses it into a JavaScript data structure, and stores it in memory.
Eval: Executes the parsed code.
Print: Outputs the result of the evaluation.
Loop: Repeats the process until you exit (using
.exit,Ctrl+Ctwice, orCtrl+D).
To start it, run node in your terminal. The REPL supports variables, functions, multi-line code, and built-in commands like .help, .clear, and .save.
Useful REPL Commands
Command | Purpose |
.help | Show commands |
.clear | Clear REPL |
. exit | Exit REPL |
. save file.js | Save session |
. load file.js | Load file |
Create your first JavaScript file
You can use both GUI and CLI to do tasks, like creating file or deleting one. At times it becomes fast to do such things with CLI. Now let’s create an actual Node.js application.
Create a folder: mkdir first-node-app Move inside it: cd first-node-app Create a file: touch app.js. (Windows users can create manually.)
Run Node.js scripts
Now open terminal inside the project folder.
Run : node app.js
Output : ‘Hello, Node.js
Node.js did several things internally:
Read the file
Parsed JavaScript code
Sent code to V8 engine
Executed it
Printed output
This is the foundation of every Node.js application.
Writing Hello World server
Now let’s create a real web server. Replace app.js code with this:
const http = require("http"); // Importing HTTP Module
const server = http.createServer((req, res) => { // This creates an HTTP server., request & response
res.end("Hello World from Node.js Server"); // sends back data to browser
});
server.listen(3000, () => { // This starts the server on port 3000.
console.log("Server running on port 3000");
});
Running the Server
Run: node app.js
Output: Server running on port 3000
Now open browser:
You’ll see:
Hello World from Node.js Server
Congratulations, You just created your first backend server.
Conclusion
Your first Node.js application may look tiny, but it introduces the core ideas behind backend development.
Today you learned how to:
Install Node.js
Use terminal commands
Work with REPL
Execute JavaScript outside browsers
Run scripts using Node
Build a real HTTP server
This is where every Node.js journey begins. The next step is not memorizing frameworks. It’s building small projects repeatedly until the runtime starts feeling natural.
Because the best way to learn backend development is by running code, breaking things, fixing them, and understanding why they work.




