Thursday, April 16, 2026

NODE.JS MINI TUTORIAL (BEGINNER FRIENDLY)

🧠 1. What is Node.js?

Node.js is a tool that allows you to run JavaScript outside the browser.

👉 Before Node.js:

  • JavaScript = only in browser

👉 With Node.js:

  • JavaScript = backend + server + apps

⚙️ 2. What Can You Do With Node.js?

  • Build web servers 🌐
  • Create APIs 🔗
  • Handle databases 🗄️
  • Build real-time apps (chat apps, etc.)

📥 3. Install Node.js

  1. Go to 👉 https://nodejs.org
  2. Download LTS version
  3. Install

👉 Check installation:

node -v
npm -v

🧪 4. Your First Node.js Program

Create a file: app.js

console.log("Hello from Node.js");

Run it:

node app.js

📦 5. What is NPM?

NPM = Node Package Manager

👉 It helps you install tools/libraries

Example:

npm init -y

Install a package:

npm install express

🌐 6. Create a Simple Server (VERY IMPORTANT 🔥)

Install Express:

npm install express

Create server.js:

const express = require("express");
const app = express();

app.get("/", (req, res) => {
res.send("Welcome to my server!");
});

app.listen(3000, () => {
console.log("Server running on port 3000");
});

Run:

node server.js

👉 Open browser:

http://localhost:3000

📁 7. File System Example

const fs = require("fs");

fs.writeFile("test.txt", "Hello File!", (err) => {
if (err) throw err;
console.log("File created!");
});

🔄 8. Modules in Node.js

// math.js
exports.add = (a, b) => a + b;
// app.js
const math = require("./math");
console.log(math.add(2, 3));

🧑‍🏫 9. Simple Teaching Flow

Day 1:

  • What is Node.js
  • Run JS outside browser

Day 2:

  • NPM & packages
  • File system

Day 3:

  • Express server
  • Routing

Day 4:

  • Mini API project

🔥 10. Mini Project Idea (For Students)

👉 Build a simple API:

app.get("/students", (req, res) => {
res.json([
{ name: "Daniel" },
{ name: "Kay" }
]);
});

🎯 11. Real-Life Use Case (Explain to Students)

“Imagine your school portal…”

  • Frontend → HTML, CSS, JS
  • Backend → Node.js
  • Database → Stores results

👉 Node.js is what connects everything

💡 PRO TIP

Node.js is easy if you already know JavaScript.

👉 Focus on:

  • Functions
  • Objects
  • Async (later stage)

NODE.JS MINI TUTORIAL (BEGINNER FRIENDLY)

🧠 1. What is Node.js? Node.js is a tool that allows you to run JavaScript outside the browser . 👉 Before Node.js: JavaScript = only in br...