Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine. It allows you to run JavaScript code outside the browser, enabling server-side development and scripting.

💡 What is a Runtime?
A runtime provides an environment where your code executes. Node.js includes the V8 engine plus additional APIs for system access like file I/O, networking, and more.
Key Components of Node Runtime
- V8 Engine: Compiles and runs JavaScript code quickly.
- Libuv: Handles asynchronous I/O operations like file system, network, and timers.
- Node API: Provides APIs for file system, networking, process management, etc.
- Event Loop: Manages asynchronous callbacks and non-blocking I/O.
| Feature | Node.js Runtime |
|---|---|
| Global Object | global |
| APIs Available | File system, Network, Child processes |
| Use Case | Server-side scripting, tooling |
| Module System | CommonJS (require/export) & ES Modules |
| Browser APIs | Not available (e.g., no DOM) |
How Node Executes JavaScript
When you run node yourfile.js, Node:
- Reads your JavaScript file.
- Passes it to the V8 engine to compile and run.
- Uses the event loop to handle asynchronous operations.
💡 Event Loop Simplified
Node's event loop lets your program handle many tasks concurrently without blocking the main thread.
Common Node Runtime Globals
global— The global object (likewindowin browsers).process— Provides info about and control over the current Node process.__dirname&__filename— Paths to the current directory and file.require— Function to import modules.
⚠️ No Browser APIs
Node.js does not include browser-specific APIs like document, window, or localStorage. For these, use browser environments or tools like jsdom.
📌 Deep Dive: Basic Node Script
console.log('Running in Node.js!');
console.log('Current directory:', __dirname);
console.log('Node version:', process.version);
Current directory: /your/current/path
Node version: v18.0.0 (example)
💡 Summary
The Node runtime is a powerful environment that enables JavaScript to run outside browsers, providing access to system resources and asynchronous capabilities through its event-driven architecture.
Quick Knowledge Check
Test what you just learned
Question 1 of 2
Which engine does Node.js use to execute JavaScript?
Question 2 of 2
Which of these is NOT available in the Node.js runtime?
Loading results...