What Is Node.js?
JavaScript that runs on a server — and why that changes what you can build
JavaScript was invented for browsers. Node.js took the JavaScript engine out of Chrome (V8) and made it run on your computer or a server. This means the same language — variables, functions, arrays, async/await — works both in the browser and on the server.
Node.js is like moving from a kitchen in a restaurant to a commercial kitchen
Browser JavaScript is like cooking in a home kitchen — you can do a lot, but you are limited by what the browser allows. Node.js is the full commercial kitchen: you can access the file system, open network connections, run background processes, and talk directly to databases.
What Node.js is used for
- REST APIs — The backend your React or Next.js app talks to — endpoints that return JSON data
- Server-side rendering — Next.js, Nuxt, SvelteKit all run on Node
- CLI tools — npm, ESLint, Prettier, and most dev tools are Node programs
- Real-time services — WebSocket servers, chat apps, live notifications
- Build tooling — Webpack, Vite, and TypeScript compiler all run on Node
Installing Node.js
Check your Node version
# Check if Node is installed: node --version # should show v18.x or higher npm --version # npm comes bundled with Node # Recommended: install via nvm (Node Version Manager) # This lets you switch between Node versions easily # macOS/Linux: curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash # Windows: use nvm-windows nvm install 22 # install Node 22 (current LTS as of 2026) nvm use 22
Your first Node program
hello.js — run with node hello.js
// Access the file system (not possible in browser JS)
const fs = require('fs')
fs.writeFileSync('hello.txt', 'Hello from Node.js!')
// Read the file back
const content = fs.readFileSync('hello.txt', 'utf8')
console.log(content) // Hello from Node.js!
// Access environment variables
console.log(process.env.HOME) // /Users/yourname on Mac