
Node.js is a JavaScript runtime that lets you run JavaScript outside the browser. It is commonly used to build web servers, APIs, command-line tools, and real-time applications.
Node.js includes the built-in http module, which can handle requests without installing additional packages:
const http = require("node:http");
const server = http.createServer((request, response) => {
response.writeHead(200, { "Content-Type": "text/plain" });
response.end("Hello from Node.js!");
});
server.listen(3000, () => {
console.log("Server running at http://localhost:3000");
});
Save the code in server.js, then run it with:
node server.js
Open http://localhost:3000 in a browser to see the response.
Node.js is a practical starting point for learning backend development and building small services.