NelsonLabs
Node.js Fundamentals/What is Node.js?

What is Node.js?

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.

What Node.js enables

  • β€”Web servers and APIs β€” the backbone of Express, Fastify, and NestJS
  • β€”Command-line tools β€” npm itself is Node.js, as is ESLint, Prettier, Vite
  • β€”File system automation β€” scripts that read, process, and write files
  • β€”Real-time apps β€” chat, live notifications, multiplayer games via WebSockets
  • β€”Build tools β€” Webpack, Babel, Next.js dev server all run on Node
Installing and verifying Node.js
bash
# 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
Your first Node.js program
javascript
// 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);