What's New in Node.js 19
The Node.js team recently announced version 19 and Node.js 18 will become Long-Term Support (LTS).
According to the Node.js release process, Node.js 19 will not be promoted to LTS as only even-numbered versions are promoted to LTS releases – like Node.js 8, Node.js 10, Node.js 12, and so on–will become LTS.
This version comes with 6 major features:
–watch
If you have used nodemon in the development process before, this feature will be very useful for you.
Node.js 19 comes with a "--watch" feature experimentally. To put it simply, your server restarts when there is a change in any file with "--watch" command line option which saves you time instead of restarting it over and over.
HTTP(S)/1.1 KeepAlive by default
const http = require("node:http");
console.log(http.globalAgent);
const https = require("node:https");
console.log(https.globalAgent);
Any outgoing HTTP(s) connection will automatically use HTTP 1.1 Keep-Alive. so HTTP won't create a new TCP connection for every request. it will use an existing connection.
if you run the code you will see keepAlive is true. Before Node.js 19 it was false
Agent {
_events: [Object: null prototype] {
free: [Function (anonymous)],
newListener: [Function: maybeEnableKeylog]
},
_eventsCount: 2,
_maxListeners: undefined,
defaultPort: 80,
protocol: 'http:',
options: [Object: null prototype] {
keepAlive: true,
scheduling: 'lifo',
timeout: 5000,
noDelay: true,
path: null
},
requests: [Object: null prototype] {},
sockets: [Object: null prototype] {},
freeSockets: [Object: null prototype] {},
keepAliveMsecs: 1000,
keepAlive: true,
maxSockets: Infinity,
maxFreeSockets: 256,
scheduling: 'lifo',
maxTotalSockets: Infinity,
totalSocketCount: 0,
[Symbol(kCapture)]: false
}
Agent {
_events: [Object: null prototype] {
free: [Function (anonymous)],
newListener: [Function: maybeEnableKeylog]
},
_eventsCount: 2,
_maxListeners: undefined,
defaultPort: 443,
protocol: 'https:',
options: [Object: null prototype] {
keepAlive: true,
scheduling: 'lifo',
timeout: 5000,
noDelay: true,
path: null
},
requests: [Object: null prototype] {},
sockets: [Object: null prototype] {},
freeSockets: [Object: null prototype] {},
keepAliveMsecs: 1000,
keepAlive: true,
maxSockets: Infinity,
maxFreeSockets: 256,
scheduling: 'lifo',
maxTotalSockets: Infinity,
totalSocketCount: 0,
maxCachedSessions: 100,
_sessionCache: { map: {}, list: [] },
[Symbol(kCapture)]: false
}
Stable WebCrypto API
The Web Crypto API is now stable in Node.js 19 with some exception of these algorithms: Ed25519
, Ed448
, X25519
, and X448
). you can check the algorithm matrix
Use globalThis.crypto
or require('node:crypto').webcrypto
to access this module.
Custom ESM resolution adjustments
Node.js has removed the --experimental-specifier-resolution
flag. Its functionality can now be achieved via custom loaders.
Dropped DTrace/SystemTap/ETW support
DTrace can be used to get an overview of the system like memory, CPU , filesystem, and network resources. The reason behind this decision is the lack of resources to keep it up-to-date.
V8 JavaScript engine is updated to V8 10.7
Node.js 19 will use version 10.7 of the V8 JavaScript engine which is part of Chromium 107. This version includes a new feature to the JavaScript API: Intl.NumberFormat
.