From b88542b653ab18c676f39b947459d3250c3536a8 Mon Sep 17 00:00:00 2001 From: Christian Aurich Zanettini Martins Date: Mon, 23 Nov 2026 07:57:24 -0300 Subject: [PATCH 1/2] sqlite: throw ERR_NO_SQLITE without SQLite support In builds configured --without-sqlite, passing --experimental-sqlite exposes node:sqlite, and loading it then fails with "No such binding: sqlite". Throw ERR_NO_SQLITE instead, like node:crypto does without OpenSSL. Signed-off-by: Christian Aurich Zanettini Martins --- doc/api/errors.md | 12 ++++++++++++ lib/internal/errors.js | 2 ++ lib/sqlite.js | 6 ++++++ test/parallel/test-sqlite-without-sqlite.js | 11 +++++++++++ 4 files changed, 31 insertions(+) create mode 100644 test/parallel/test-sqlite-without-sqlite.js diff --git a/doc/api/errors.md b/doc/api/errors.md index 712d73cc140e..ed0f06ffa8a7 100644 --- a/doc/api/errors.md +++ b/doc/api/errors.md @@ -2548,6 +2548,17 @@ OpenSSL crypto support. An attempt was made to use features that require [ICU][], but Node.js was not compiled with ICU support. + + +### `ERR_NO_SQLITE` + + + +An attempt was made to use [`node:sqlite`][], but Node.js was not compiled with +SQLite support. + ### `ERR_NO_TEMPORAL` @@ -4872,6 +4883,7 @@ An error occurred trying to allocate memory. This should never happen. [`new URL(input)`]: url.md#new-urlinput-base [`new URLPattern(input)`]: url.md#new-urlpatternstring-baseurl-options [`new URLSearchParams(iterable)`]: url.md#new-urlsearchparamsiterable +[`node:sqlite`]: sqlite.md [`package.json`]: packages.md#nodejs-packagejson-field-definitions [`postMessage()`]: worker_threads.md#portpostmessagevalue-transferlist [`postMessageToThread()`]: worker_threads.md#worker_threadspostmessagetothreadthreadid-value-transferlist-timeout diff --git a/lib/internal/errors.js b/lib/internal/errors.js index 78d3de196a52..28f7409ec7f1 100644 --- a/lib/internal/errors.js +++ b/lib/internal/errors.js @@ -1650,6 +1650,8 @@ E('ERR_NO_CRYPTO', 'Node.js is not compiled with OpenSSL crypto support', Error); E('ERR_NO_ICU', '%s is not supported on Node.js compiled without ICU', TypeError); +E('ERR_NO_SQLITE', + 'Node.js is not compiled with SQLite support', Error); E('ERR_NO_TEMPORAL', 'Temporal is not supported in this environment', Error); E('ERR_NO_TYPESCRIPT', diff --git a/lib/sqlite.js b/lib/sqlite.js index 4934a4b7700a..5770583c5e4a 100644 --- a/lib/sqlite.js +++ b/lib/sqlite.js @@ -1,5 +1,11 @@ 'use strict'; +const { ERR_NO_SQLITE } = require('internal/errors').codes; + +if (!process.versions.sqlite) { + throw new ERR_NO_SQLITE(); +} + const { Database, Statement, Session, constants, backup } = internalBinding('sqlite'); diff --git a/test/parallel/test-sqlite-without-sqlite.js b/test/parallel/test-sqlite-without-sqlite.js new file mode 100644 index 000000000000..ee1a44e44f80 --- /dev/null +++ b/test/parallel/test-sqlite-without-sqlite.js @@ -0,0 +1,11 @@ +// Flags: --experimental-sqlite +'use strict'; + +const { hasSQLite } = require('../common'); +const assert = require('node:assert'); + +if (hasSQLite) { + assert.strictEqual(typeof require('node:sqlite').Database, 'function'); +} else { + assert.throws(() => require('node:sqlite'), { code: 'ERR_NO_SQLITE' }); +} From d27501bdc164051845a71a0a9ac928493d5f9fce Mon Sep 17 00:00:00 2001 From: Christian Aurich Zanettini Martins Date: Mon, 23 Nov 2026 10:23:35 -0300 Subject: [PATCH 2/2] cli: remove --no-experimental-sqlite flag node:sqlite is stable, so it no longer needs an opt-out. --experimental-sqlite stays as an undocumented no-op, like --experimental-websocket. Builds without SQLite now expose the module, which throws ERR_NO_SQLITE when loaded. Signed-off-by: Christian Aurich Zanettini Martins --- doc/api/cli.md | 17 +---------- doc/api/sqlite.md | 7 +++++ doc/node-config-schema.json | 4 --- doc/node.1 | 7 ++--- lib/internal/bootstrap/realm.js | 2 +- src/node_options.cc | 6 +--- src/node_options.h | 1 - test/parallel/test-sqlite-session.js | 2 +- test/parallel/test-sqlite-without-sqlite.js | 1 - test/parallel/test-sqlite.js | 31 +++++++++++++-------- 10 files changed, 33 insertions(+), 45 deletions(-) diff --git a/doc/api/cli.md b/doc/api/cli.md index a4e27926b00c..0470c96c2dcf 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -2352,20 +2352,6 @@ changes: Legacy alias for [`--no-require-module`][]. -### `--no-experimental-sqlite` - - - -Disable the [`node:sqlite`][] module. - ### `--no-experimental-vfs`