## glossary
What is Node.js?
Node.js is a runtime environment that lets you run JavaScript outside the browser. Created in 2009 by Ryan Dahl, it combines Chrome’s V8 engine with an asynchronous I/O library, giving JavaScript access to files, networking and system processes.
The impact was structural: for the first time, the same language served both frontend and backend. That reduced context switching within teams and made it possible to share validation code and types between the two ends.
The asynchronous, non-blocking model
Traditional servers usually spawn one thread per connection, which consumes memory and limits scale. Node uses a single main thread with an event loop: when a slow operation starts, it is delegated to the system and the thread keeps serving other requests.
import { readFile, readFileSync } from 'fs';
// blocking: freezes the thread until it finishes
const dados = readFileSync('relatorio.csv', 'utf8');
console.log('depois da leitura');
// non-blocking: keeps going and comes back when done
readFile('relatorio.csv', 'utf8', (erro, dados) => {
console.log('leitura concluída');
});
console.log('isto imprime primeiro');That model makes Node excellent for I/O-heavy workloads — APIs, proxies, streaming, real time. And it makes it a poor fit for CPU-heavy processing: one long computation freezes the single thread and kills responsiveness for every request.
npm: the ecosystem as the differentiator
npm is the package registry that ships with Node and the largest library repository in the world. Alternatives like Yarn and pnpm resolve the same dependencies with different caching and disk strategies — a detailed comparison is in package managers. To run packages without installing them globally, there is npx, explained in introduction to npx.
Precautions in production
- Do not block the event loop — heavy work belongs in worker threads or a separate service.
- Handle unhandled rejections — a rejected Promise without a catch can bring down the process.
- Audit dependencies — the ease of installing packages is also the ecosystem’s biggest attack surface.
- Use multiple processes — the cluster module or a manager like PM2 makes use of every core on the machine.
- Pin the Node version — behavior changes across major versions; declare the version in the project.
## faq
Frequently asked questions
Is Node.js a programming language?
No. Node.js is a runtime environment. The language is JavaScript. Node provides the engine that executes the code and the APIs for accessing the file system, networking and processes.
Can Node.js handle large-scale applications?
Yes. Netflix, PayPal, LinkedIn and Uber run critical services on Node. Scale comes from the architecture — multiple instances, load balancing and queues — not from a single instance handling everything alone.
What is the difference between Node.js and Deno or Bun?
Deno and Bun are newer runtimes that execute JavaScript and TypeScript with distinct goals: Deno prioritizes security through explicit permissions, and Bun prioritizes execution and package-install speed. Node remains the most mature and the most compatible with the existing ecosystem.