Chapter 1 of 12
Node.js is JavaScript that runs outside the browser. Before Node.js (released in 2009), JavaScript only worked in browsers. Node opened up server-side development, CLIs, scripts, and entire backends to JavaScript developers.
ANALOGY
Same engine, different vehicle. Your car's engine can power a boat if you mount it differently. Node.js took the V8 JavaScript engine that powers Chrome and mounted it on a server β the same engine, same language, but now it can handle files, networks, databases, and operating system calls instead of browser DOM manipulation.
# Download from nodejs.org β get the LTS (Long Term Support) version
# After installation, verify it works:
node --version # v20.x.x (or similar)
npm --version # 10.x.x
# Run a JavaScript file
node myfile.js
# Start a REPL (interactive console)
node// hello.js
console.log("Hello from Node.js!");
// Access process information
console.log("Node version:", process.version);
console.log("Platform:", process.platform);
console.log("Working directory:", process.cwd());
// Arguments passed to the script
// Run: node hello.js --name Nelson
const args = process.argv.slice(2); // [0] = node, [1] = file path
console.log("Arguments:", args);