Node.js 22 Promoted to LTS
On October 29, 2024, Node.js 22 was promoted to LTS (Long Term Support) version. LTS versions are guaranteed 30 months of support.
Upgrade Recommended: Node.js 18 is scheduled to end support in April 2025. Plan your migration to Node.js 22.
Key New Features
1. require(esm) Support
ES modules can now be loaded directly with require() from CommonJS modules. This makes mixing CommonJS and ESM easier.
// Load ESM from CommonJS
const esModule = require('./esm-module.mjs');
2. WebSocket Client API
Browser-compatible WebSocket class is now available by default. WebSocket communication is possible without external libraries.
const ws = new WebSocket('wss://example.com/socket');
ws.addEventListener('open', () => {
ws.send('Hello Server!');
});
ws.addEventListener('message', (event) => {
console.log('Received:', event.data);
});
3. Experimental TypeScript Support
With the --experimental-strip-types flag, TypeScript files can be executed directly.
# Execute TypeScript file directly
node --experimental-strip-types app.ts
4. V8 Engine Upgrade
Upgraded to V8 12.4, enabling the following new features:
Array.fromAsync()- Generate arrays from async iteratorsSetmethod additions -union(),intersection(), etc.- Regular expression
/vflag
5. Environment Variable File Loading
Load .env files with the --env-file flag.
# Load .env file and execute
node --env-file=.env app.js
Breaking Changes
url.parse()deprecated (useURLconstructor)fs.exists()removed- Old SSL/TLS protocols disabled by default
Summary
Node.js 22 adds features that significantly improve developer experience, including ESM and CommonJS compatibility improvements, WebSocket standardization, and direct TypeScript execution. Before applying to production, verify the impact of breaking changes.
← Back to list