Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions doc/api/errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions lib/internal/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
6 changes: 6 additions & 0 deletions lib/sqlite.js
Original file line number Diff line number Diff line change
@@ -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');

Expand Down
11 changes: 11 additions & 0 deletions test/parallel/test-sqlite-without-sqlite.js
Original file line number Diff line number Diff line change
@@ -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' });
}
Loading