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>
This commit is contained in:
Christian Aurich Zanettini Martins authored and GitHub committed 2026-11-25 12:37:21 +00:00
1 parent ffc57f007f
commit 18bb2e5e0e
4 files changed
+31

No files matched your search

+12
View File
@@ -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
+2
View File
@@ -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',
+6
View File
@@ -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');
@@ -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' });
}