Member-only story
What’s new in Node.js 22.5.0
3 min readJul 18, 2024
Yesterday, the latest version of Node.js 22.5.0 released, and with that some cool features introduced.
if you don’t have a Medium premium account, you can read this article free with this link
Here are some of the highlights:
- Experimental node:sqlite module 🔥
- Support for glob matching on Node.js test runner
- New worker.postMessageToThread API, and more!
Experimental node:sqlite module
Node.js now includes a built-in sqlite module (require('node:sqlite')
) that becomes available when using the --experimental-sqlite
flag.
Here is a basic example of how to use node:sqlite
:
import { DatabaseSync } from 'node:sqlite';
const database = new DatabaseSync(':memory:');
// Execute SQL statements from strings.
database.exec(`
CREATE TABLE data(
key INTEGER PRIMARY KEY,
value TEXT
) STRICT
`);
// Create a prepared statement to insert data into the database.
const insert = database.prepare('INSERT INTO data (key, value) VALUES (?, ?)');
// Execute the prepared statement with bound values.
insert.run(1, 'hello');
insert.run(2, 'world');
// Create a prepared statement to read data from the database.
const query = database.prepare('SELECT * FROM data ORDER BY key');
//…