Node.js 22 is the current LTS release — and it comes with powerful free built-in APIs that replace dozens of npm packages.
What's New in Node 22?
Node 22 shipped features that eliminate entire categories of dependencies:
- Built-in test runner — no more Jest/Vitest
- Native watch mode — no more nodemon
-
--env-file— no more dotenv -
Glob support in
node:fs— no more glob package - WebSocket client — native, no ws package
-
node --run— scripts without package.json
The Free APIs You're Not Using
1. Built-in Test Runner (replaces Jest)
import { describe, it } from "node:test";
import assert from "node:assert/strict";
describe("User API", () => {
it("creates a user", async () => {
const res = await fetch("http://localhost:3000/users", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ name: "Alex" })
});
assert.equal(res.status, 201);
const user = await res.json();
assert.equal(user.name, "Alex");
});
it("handles invalid input", async () => {
const res = await fetch("http://localhost:3000/users", {
method: "POST",
body: "invalid"
});
assert.equal(res.status, 400);
});
});
Run with: node --test
2. Watch Mode (replaces nodemon)
# Auto-restart on file changes
node --watch server.js
# Watch specific files
node --watch-path=./src server.js
Zero install. Zero config. Just works.
3. Environment Files (replaces dotenv)
# .env
DATABASE_URL=postgresql://localhost:5432/mydb
API_KEY=sk-1234567890
# Load automatically
node --env-file=.env server.js
4. Native Glob (replaces glob package)
import { globSync } from "node:fs";
// Find all TypeScript files
const files = globSync("src/**/*.ts");
console.log(files);
// Find all test files
const tests = globSync("**/*.test.{js,ts}");
5. Native WebSocket Client
const ws = new WebSocket("wss://echo.websocket.org");
ws.addEventListener("open", () => {
ws.send("Hello from Node 22!");
});
ws.addEventListener("message", (event) => {
console.log("Received:", event.data);
});
No ws package. No socket.io-client. Built into the runtime.
6. Permission Model (experimental)
# Allow only network access to specific domains
node --experimental-permission --allow-fs-read=./data --allow-net=api.example.com server.js
Deno-like security model, now in Node.js.
Quick Comparison: Before vs After Node 22
| Before (npm install) | After (built-in) |
|---|---|
jest / vitest
|
node --test |
nodemon |
node --watch |
dotenv |
node --env-file |
glob |
node:fs globSync |
ws |
new WebSocket() |
node-fetch |
fetch() (since Node 18) |
uuid |
crypto.randomUUID() |
That's 7 fewer dependencies in your package.json.
Real Example: API Server Without Dependencies
import { createServer } from "node:http";
import { readFile, writeFile, globSync } from "node:fs";
const PORT = process.env.PORT || 3000;
const server = createServer(async (req, res) => {
const url = new URL(req.url, `http://localhost:${PORT}`);
if (url.pathname === "/api/health") {
res.writeHead(200, { "Content-Type": "application/json" });
res.end(JSON.stringify({
status: "ok",
node: process.version,
uptime: process.uptime()
}));
return;
}
res.writeHead(404);
res.end("Not found");
});
server.listen(PORT, () => {
console.log(`Server running on http://localhost:${PORT}`);
});
Zero dependencies. Production-ready.
Need to scrape data from any website and get it in structured JSON? Check out my web scraping tools on Apify — no coding required, results in minutes.
Have a custom data extraction project? Email me at spinov001@gmail.com — I build tailored scraping solutions for businesses.
Top comments (0)