Setting Up Your First Node.js Application Step-by-Step
Step 1: Installing Node.js
Go to the official website: https://nodejs.org
Download the LTS (Long Term Support) version
Install it like any standard application
๐ LTS is recommended because it's stable and widely supported.
Step 2: Verify Installation
Open your terminal (Linux/macOS) or command prompt (Windows) and run:
node -v
You should see something like:
v20.x.x
Also check npm (Node Package Manager):
npm -v
Step 3: Understanding Node REPL
REPL = Read โ Eval โ Print โ Loop
Start it by typing:
node
Now you can run JavaScript directly:
> console.log("Hello Node")
Hello Node
Why REPL matters:
Quick testing
Debugging small snippets
Learning JS behavior interactively
Exit REPL:
.exit
Step 4: Create Your First JavaScript File
Create a file:
touch app.js
Or manually create app.js and add:
console.log("Hello from Node.js!");
Step 5: Run the Script
Execute the file using:
node app.js
Output:
Hello from Node.js!
This confirms your Node environment is working correctly.
Step 6: Create a Simple "Hello World" Server
Now letโs build a basic HTTP server.
Update app.js:
const http = require("http");
const server = http.createServer((req, res) => {
res.end("Hello World from Node.js Server!");
});
server.listen(3000, () => {
console.log("Server is running on http://localhost:3000");
});

