Node.js is a JavaScript runtime built on Chrome’s V8 engine. It enables server-side JavaScript execution, powering everything from web servers to CLI tools, making JavaScript a full-stack language.
📑 Table of Contents
Key Features
- Event-Driven: Non-blocking I/O model
- npm Ecosystem: Largest package registry
- Single Language: JavaScript front-to-back
- High Performance: V8 engine optimization
- Active Community: Extensive tooling and frameworks
Installation
Install Node.js on Ubuntu:
# Using NodeSource
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt install nodejs
# Verify installation
node --version
npm --version
Usage Examples
Node.js examples:
// HTTP server
const http = require("http");
const server = http.createServer((req, res) => {
res.writeHead(200, {"Content-Type": "text/plain"});
res.end("Hello World");
});
server.listen(3000);
// File operations
const fs = require("fs").promises;
async function readFile() {
const data = await fs.readFile("file.txt", "utf8");
console.log(data);
}
Benefits
Node.js enables full-stack JavaScript development. Its asynchronous nature excels at handling concurrent connections, making it ideal for real-time applications.
Was this article helpful?