Hello, Node.js! — Your First Server-Side Program
⏱ 15 min read
Node.js is a JavaScript runtime built on Chrome's V8 engine. It lets you run JavaScript outside the browser — on servers, your laptop, or anywhere.
How Node.js Works:
Before Node.js (2009), JavaScript only ran inside browsers. Ryan Dahl changed that by embedding V8 into a standalone runtime.
Node.js uses an event-driven, non-blocking I/O model — it handles thousands of connections simultaneously without waiting for each one to finish.
This is why Node.js is extremely popular for web servers, REST APIs, and real-time apps.
JavaScript runs everywhere now:
Browser — handles clicks, animations, and the DOM
Node.js — handles files, networks, databases, and servers
How to Install and Run:
1. Download Node.js from nodejs.org (includes npm — the package manager)
2. Save your file as hello.js
3. Open a terminal and run: node hello.js
Breaking Down Hello World:
console.log(...) — prints to the terminal. Equivalent to System.out.println() in Java or print() in Python.
process — a global object in Node.js giving info about the running process:
process.version — Node.js version
process.platform — 'linux', 'win32', 'darwin'
process.argv — command-line arguments passed to your script
__filename — full path to the current file
__dirname — full path to the current directory
Comments in JavaScript:
// This is a single-line comment
/* This is a multi-line comment */
JavaScript ignores all comments — they are notes for humans only.
How Node.js Works:
Before Node.js (2009), JavaScript only ran inside browsers. Ryan Dahl changed that by embedding V8 into a standalone runtime.
Node.js uses an event-driven, non-blocking I/O model — it handles thousands of connections simultaneously without waiting for each one to finish.
This is why Node.js is extremely popular for web servers, REST APIs, and real-time apps.
JavaScript runs everywhere now:
Browser — handles clicks, animations, and the DOM
Node.js — handles files, networks, databases, and servers
How to Install and Run:
1. Download Node.js from nodejs.org (includes npm — the package manager)
2. Save your file as hello.js
3. Open a terminal and run: node hello.js
Breaking Down Hello World:
console.log(...) — prints to the terminal. Equivalent to System.out.println() in Java or print() in Python.
process — a global object in Node.js giving info about the running process:
process.version — Node.js version
process.platform — 'linux', 'win32', 'darwin'
process.argv — command-line arguments passed to your script
__filename — full path to the current file
__dirname — full path to the current directory
Comments in JavaScript:
// This is a single-line comment
/* This is a multi-line comment */
JavaScript ignores all comments — they are notes for humans only.
Log in to track your progress and earn badges as you complete lessons.
Log In to Track Progress