Commit 18bb2e5e0e0 for nodejs

commit 18bb2e5e0e075f6f286310f2b08ebf7afcc507e7
Author: Christian Aurich Zanettini Martins <christian.aurichzm@gmail.com>
Date:   Wed Nov 25 09:37:21 2026 -0300

    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 <christian.aurichzm@gmail.com>
    PR-URL: https://github.com/nodejs/node/pull/67727
    Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
    Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
    Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
    Reviewed-By: Guilherme Araújo <arauujogui@gmail.com>

diff --git a/doc/api/errors.md b/doc/api/errors.md
index 712d73cc140..ed0f06ffa8a 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.

+<a id="ERR_NO_SQLITE"></a>
+
+### `ERR_NO_SQLITE`
+
+<!-- YAML
+added: REPLACEME
+-->
+
+An attempt was made to use [`node:sqlite`][], but Node.js was not compiled with
+SQLite support.
+
 <a id="ERR_NO_TEMPORAL"></a>

 ### `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 78d3de196a5..28f7409ec7f 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 4934a4b7700..5770583c5e4 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 00000000000..ee1a44e44f8
--- /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' });
+}