Node.js is an open-source server-side platform built on Chrome's V8 JavaScript engine. It allows developers to run JavaScript outside of a browser, making it ideal for building scalable network applications.
Getting Started ✅
- Install Node.js
Download from nodejs.org and follow the installation guide for your OS. - Verify Installation
Open terminal and run:
📌 Expected output: version numbers for Node.js and npm.node -v npm -v
Core Concepts 🧠
- Event Loop: Handles asynchronous operations (⏰)
- Non-blocking I/O: Efficient handling of multiple requests (🔄)
- Modules: Reusable code components (📦)
- npm: Package manager for JavaScript (📦)
Simple Example 🧪
Create a file hello.js
with:
const http = require('http');
http.createServer((req, res) => {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello, Node.js!\n');
}).listen(3000, '127.0.0.1');
console.log('Server running at http://127.0.0.1:3000/');