📖 Notes LESSON 24 OF 32

Node.js Intro

⏱️ 26 min
🟢 Node.js

JavaScript, Now on the Server

Node.js runs JavaScript outside the browser using Chrome's V8 engine, letting you write the backend in the same language as your frontend.

What Node.js Actually Is

⚙️
V8 Engine
The same JS engine that powers Chrome, embedded to run JS outside the browser.
🔁
Event Loop
Node is single-threaded but non-blocking — I/O operations run in the background and callbacks fire when they finish.
📦
npm
Node's package manager — installs and manages third-party libraries like Express.
🌐
http module
Node's built-in module for creating a raw web server, no framework required.
A Raw HTTP Server
JS
const http = require('http');

const server = http.createServer((req, res) => {
  res.writeHead(200, { 'Content-Type': 'text/plain' });
  res.end('Hello from Node!');
});

server.listen(3000, () => {
  console.log('Server running on port 3000');
});
💡
Why the next lesson uses Express instead
Writing routing, JSON parsing, and error handling manually with the raw http module gets repetitive fast — Express (Lesson 25) wraps this exact same server pattern in a much simpler API.
🗒 Cheat Sheet 📝 Worksheet