You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`@homeofthings/sqlite3` uses [Node-API](https://nodejs.org/api/n-api.html) so prebuilt binaries do not need to be built for specific Node versions. Prebuilt binaries are available for Node-API v3 and v6. Check the [Node-API version matrix](https://nodejs.org/api/n-api.html#node-api-version-matrix) to ensure your Node version supports one of these. Requires Node.js v20.17.0 or later.
39
+
`@homeofthings/sqlite3` uses [Node-API](https://nodejs.org/api/n-api.html) so prebuilt binaries do not need to be built for specific Node versions. Prebuilt binaries are built as NAPI-version-agnostic (`node.napi.*.node`) using the `--napi` flag, and work on any Node.js version that supports the NAPI version used at compile time. Requires Node.js v20.17.0 or later.
40
40
41
-
The module uses [`prebuild-install`](https://github.com/prebuild/prebuild-install) to download the prebuilt binary for your platform, if it exists. These binaries are hosted on GitHub Releases. The following targets are currently provided:
41
+
Prebuilt binaries are bundled inside the npm package using [`prebuildify`](https://github.com/prebuild/prebuildify) and loaded at runtime by [`node-gyp-build`](https://github.com/prebuild/node-gyp-build). No separate download step is needed — `npm install` just works. The following targets are currently provided:
42
42
43
43
*`darwin-arm64`
44
44
*`darwin-x64`
45
-
*`linux-arm64`
46
-
*`linux-x64`
47
-
*`linuxmusl-arm64`
48
-
*`linuxmusl-x64`
45
+
*`linux-arm64` (glibc)
46
+
*`linux-x64` (glibc)
47
+
*`linux-arm64` (musl)
48
+
*`linux-x64` (musl)
49
49
*`win32-x64`
50
50
51
-
Unfortunately, [prebuild](https://github.com/prebuild/prebuild/issues/174) cannot differentiate between `armv6` and `armv7`, and instead uses `arm` as the `{arch}`. Until that is fixed, you will still need to install `sqlite3` from [source](#source-install).
52
-
53
51
Support for other platforms and architectures may be added in the future if CI supports building on them.
54
52
55
-
If your environment isn't supported, it'll use `node-gyp` to build SQLite, but you will need to install a C++ compiler and linker.
53
+
If your platform isn't supported, `node-gyp-build` automatically falls back to building from source using `node-gyp`. For custom builds (e.g., SQLCipher, external SQLite), use `--build-from-source`:
If building against an external sqlite3 make sure to have the development headers available. Mac OS X ships with these by default. If you don't have them installed, install the `-dev` package with your package manager, e.g. `apt-get install libsqlite3-dev` for Debian/Ubuntu. Make sure that you have at least `libsqlite3` >= 3.6.
142
144
143
145
Note, if building against homebrew-installed sqlite on OS X you can do:
The default sqlite file header is "SQLite format 3". You can specify a different magic, though this will make standard tools and libraries unable to work with your files.
Copy file name to clipboardExpand all lines: docs/DEVELOP.md
+10-7Lines changed: 10 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,9 +22,9 @@ This project uses [npm version](https://docs.npmjs.com/cli/v10/commands/npm-vers
22
22
```
23
23
24
24
The CI workflow will automatically:
25
-
- Build binaries for all platforms
26
-
- Upload them as release assets
27
-
- Publish the package to npm
25
+
- Build prebuilt binaries for all platforms
26
+
- Upload them to GitHub Release
27
+
- Publish the package to npm (with bundled prebuilt binaries)
28
28
29
29
3.** Edit the generated Pre-release
30
30
- select "Generate release notes" and adjust them to your needs
@@ -44,12 +44,15 @@ When you push a tag (e.g., `v6.0.2`), the CI workflow will:
44
44
45
45
1. Build prebuilt binaries for:
46
46
- macOS (x64, arm64)
47
-
- Linux (x64, arm64)
48
-
- Windows (x64, ia32)
47
+
- Linux glibc (x64, arm64)
48
+
- Linux musl (x64, arm64)
49
+
- Windows (x64)
49
50
50
51
2. Upload binaries to GitHub Release
51
52
52
-
3. Publish to npm using trusted publishing (no NPM_TOKEN required)
53
+
3. Merge all prebuilt binaries into the npm package and publish to npm
54
+
55
+
On PRs and pushes to main (non-tag), the CI also creates an npm tarball artifact (via `npm pack`) so the package contents can be inspected before publishing.
# Install with prebuilt binaries or compile from source
61
61
yarn install
62
62
63
63
# Explicit rebuild
@@ -125,17 +125,11 @@ The `NAPI_VERSION` define is set via `napi_build_version` variable in binding.gy
125
125
**How it works**:
126
126
- The `napi_build_version` variable is automatically set by node-gyp based on the target Node.js version
127
127
- For local builds, it's stored in `build/config.gypi` (e.g., `"napi_build_version": "9"`)
128
-
- For prebuilds, the `prebuild` package passes it via `--napi_build_version=<version>` flag
128
+
- For prebuilds, `prebuildify`passes it via the `--napi` flag which builds a single NAPI-version-agnostic binary (named `@homeofthings+sqlite3.<libc>.node`). The actual NAPI version used at compile time is determined by the Node.js version running the build (e.g., Node 24 supports NAPI v9). Since NAPI is backward compatible, a binary built with NAPI v9 runs on any Node.js supporting v9 or lower.
129
129
130
130
### NAPI Versions Configuration
131
131
132
-
The `package.json` specifies which NAPI versions to build prebuilt binaries for:
133
-
134
-
```json
135
-
"binary": {
136
-
"napi_versions": [3, 6]
137
-
}
138
-
```
132
+
With `prebuildify --napi`, the NAPI version is auto-detected from the build Node.js version — it is not explicitly configured. The CI builds prebuilds on Node 24 (which supports NAPI v9), producing a single `@homeofthings+sqlite3.glibc.node` binary per platform. The historical `[3, 6]` configuration from the old `binary.napi_versions` package.json field is no longer used.
139
133
140
134
**Why multiple versions?**
141
135
@@ -183,40 +177,65 @@ The `ASSERT_STATUS` macro in src/macros.h is enabled when `DEBUG` is defined:
183
177
The native addon is loaded via lib/sqlite3-binding.js:
The project root directory (`path.join(__dirname, "..")`) is passed instead of `__dirname` because `node-gyp-build` looks for `prebuilds/` and `build/` directories relative to the path it receives. Since `sqlite3-binding.js` is in `lib/`, passing `__dirname` would cause it to look in `lib/prebuilds/` and `lib/build/` — which do not exist.
192
184
193
-
**Note**: Debug builds take precedence if both exist.
185
+
The `node-gyp-build` package resolves the native binary in this order:
186
+
1.`build/Release/node_sqlite3.node` — local release build
187
+
2.`build/Debug/node_sqlite3.node` — local debug build
**Note**: Local builds take precedence over prebuilt binaries. To force a source build (which creates `build/Release/` and takes precedence), use `npm install --build-from-source`.
196
191
197
-
### Downloading Prebuilts
192
+
##Prebuilt Binaries
198
193
199
-
```bash
200
-
yarn install # Automatically downloads prebuilt if available
201
-
```
194
+
Prebuilt binaries are bundled inside the npm package using `prebuildify` and loaded at runtime by `node-gyp-build`. This eliminates the need for a separate download step during `npm install`.
202
195
203
196
### Building Prebuilts
204
197
205
198
```bash
206
-
yarn prebuild # Build for all NAPI versions
199
+
yarn prebuild # Build prebuilt binaries using prebuildify
207
200
```
208
201
209
-
### Uploading Prebuilts
202
+
The `prebuild` script runs: `prebuildify --napi --strip --tag-libc`
203
+
204
+
Flags:
205
+
-`--napi`: Build a NAPI-version-agnostic binary (produces `@homeofthings+sqlite3.*.node`)
206
+
-`--strip`: Strip debug symbols from binaries
207
+
-`--tag-libc`: Tag binaries with libc variant (glibc vs musl)
208
+
209
+
### Binary Naming Convention
210
+
211
+
With `--tag-libc`, prebuildify produces binaries tagged with the libc variant:
212
+
213
+
| Platform | Binary Name |
214
+
|---------------|------------------------|
215
+
| Linux (glibc) |`@homeofthings+sqlite3.glibc.node`|
216
+
| Linux (musl) |`@homeofthings+sqlite3.musl.node`|
217
+
| macOS |`@homeofthings+sqlite3.node`|
218
+
| Windows |`@homeofthings+sqlite3.node`|
219
+
220
+
At runtime, `node-gyp-build` determines the libc variant by checking for Alpine Linux (via `/etc/alpine-release`) — if present, it selects the `musl` binary; otherwise, it selects `glibc`. It does not depend on the `detect-libc` package.
221
+
222
+
### Source Build Fallback
223
+
224
+
The `install` script runs `node-gyp-build` which tests whether the prebuilt binary works. If it does, no compilation is needed. If it doesn't (unsupported platform), `node-gyp-build` automatically falls back to `node-gyp rebuild`.
225
+
226
+
For custom builds (e.g., SQLCipher), use `--build-from-source` to skip the prebuilt test and force compilation:
The `--build-from-source` flag is handled by the `node-gyp-build` CLI (not `prebuild-install`). It checks `npm_config_build_from_source` and skips the prebuilt test, going straight to `node-gyp rebuild`.
233
+
215
234
## Platform Support
216
235
217
236
- Node.js >= 20.17.0
218
-
- NAPI versions: 3, 6
219
-
- Platforms: Linux, macOS, Windows (see prebuild configuration)
237
+
- NAPI: version-agnostic (`@homeofthings+sqlite3.*.node`), built with NAPI v9 on Node 24
238
+
- Platforms: Linux (glibc + musl), macOS, Windows (see CI configuration)
220
239
221
240
## Security Hardening
222
241
@@ -305,9 +324,10 @@ Applied to all macOS builds (see `binding.gyp`):
0 commit comments