Overview
- 1Node.js 22 (LTS since Oct 2024, supported until Apr 2027) is the recommended version for production.
- 2Built-in `node:sqlite` module eliminates the need for better-sqlite3 in many use cases.
- 3process.loadEnvFile() loads .env files natively — no need to install dotenv.
- 4require() can now import ES modules with `--experimental-require-module` flag.
- 5The built-in test runner (node:test) is now production-grade with TAP output.
Key Features in 22 LTS
Use Cases
- →REST and GraphQL API servers
- →Real-time applications with WebSockets
- →CLI tools and scripts
- →Serverless functions (AWS Lambda, Vercel, Cloudflare Workers)
What's New in Node.js 22
- `node:sqlite` module: `import { DatabaseSync } from "node:sqlite"` — synchronous SQLite
- process.loadEnvFile(".env") loads key=value pairs from a file into process.env
- glob("**/*.js", { cwd }) built into node:path — no glob package needed
- require(esm) works with --experimental-require-module flag
- WebSocket client API stable — `new WebSocket(url)` without ws package
- Stream improvements: composing readable/writable streams is simpler with pipeline()
Core Modules
- http/https: createServer, IncomingMessage, ServerResponse
- fs/promises: readFile, writeFile, mkdir, watch, readdir (async/await versions)
- path: join, resolve, dirname, basename, extname
- url: URL, URLSearchParams — parse and build URLs
- crypto: createHash, randomBytes, pbkdf2, generateKeyPair
- worker_threads: offload CPU-intensive work to separate V8 isolates
- child_process: exec, spawn, fork for running external commands
Web Frameworks — Express & Fastify
- Express 5.x: async error handling, route.route() chaining, no more req.param()
- Fastify 4.x: JSON schema validation, hooks, plugins, 3x faster than Express
- Hono — ultra-fast framework for edge (Cloudflare Workers, Vercel Edge)
- tRPC — end-to-end type-safe APIs between Node.js and TypeScript clients
- NestJS — opinionated, Angular-inspired framework with DI and modules
- Middleware: body-parser (built into Express 5), cors, helmet, morgan
Performance & Production
- Cluster module: fork workers equal to CPU cores for load distribution
- Node.js --prof: V8 profiling; process with node --prof-process
- clinic.js: flame graphs and bubbleprof for deep performance analysis
- pm2: process manager with clustering, restart on crash, log management
- Avoid blocking the event loop: offload CPU work to worker_threads or subprocesses
- Connection pooling for databases (pg-pool, mongoose poolSize)
Frequently Asked Questions
What Node.js version should I use in production in 2026?
Node.js 22 LTS (Long-Term Support) is the recommended production version — active support until October 2025, then security-only until April 2027. Avoid odd-numbered versions (21, 23) for production as they are Current releases without LTS guarantees.
Do I still need dotenv with Node.js 22?
For basic .env loading, no. Node.js 22 ships `process.loadEnvFile(".env")` which reads a .env file and merges it into process.env synchronously. For advanced features like variable expansion, multi-environment support, or dotenv-flow, the dotenv package still adds value.
Node.js vs Deno vs Bun — which runtime to choose?
Node.js 22 remains the safest production choice with the largest ecosystem and enterprise support. Bun is significantly faster for startup and bundling — ideal for scripts and edge deployments. Deno offers native TypeScript, built-in testing, and a security-by-default model. For most applications, Node.js 22 LTS is the default choice.