Node.js is a runtime that lets JavaScript run outside the browser, on servers and the command line. Before Node, JavaScript could only run inside a web browser; Node took Google Chrome's V8 engine and wrapped it with APIs for files, networking, and the operating system, so the same language can now power backends, tools, and desktop apps. It was created by Ryan Dahl in 2009.
Key Features -
- V8 Engine : The core that compiles JavaScript straight to machine code, the same engine used in Chrome. Node adds a C++ layer (libuv) on top for I/O.
- Single-Threaded : Node runs your JavaScript on one main thread, unlike traditional servers that spawn a new thread per request.
- Non-Blocking & Event-Driven : Instead of waiting for slow operations (reading a file, a database query) to finish, Node starts them, continues with other work, and handles the result later through callbacks. This is what lets one thread serve thousands of connections.
- Asynchronous : I/O operations run in the background and notify your code when done, so the server is never idle while waiting.
- Fast : V8 plus non-blocking I/O makes Node very fast for network and I/O work.
- Huge Ecosystem : The npm registry offers over a million ready-to-use packages.
- One Language, Full Stack : The same JavaScript runs on both the front end and back end.
- Cross-Platform : The same code runs on Windows, macOS, and Linux.
- Scalable : The event-driven model handles many concurrent connections with little memory.
// hello.js -> run with: node hello.js
console.log("Hello from Node.js");
console.log("Node version:", process.version);