how to get better-sqlite3 to work in docker

hello. I'm getting this error when trying to run a t3 app with better-sqlite3, which I'm using with lucia auth to run and I tried using a newer node alpine image (18 and 21). The error is very similar to the one reported here https://github.com/TryGhost/node-sqlite3/issues/1581
Error: Error relocating /app/node_modules/better-sqlite3/build/Release/better_sqlite3.node: fcntl64: symbol not found
Error: Error relocating /app/node_modules/better-sqlite3/build/Release/better_sqlite3.node: fcntl64: symbol not found
any help would be appreciated.
GitHub
Prebuilt Binaries from 5.0.3 causing errors in node:16-alpine docke...
I have a node app running in a node:16-alpine docker image, and the application starts fine, but when it tries to load sqlite and use it, I get the following stack trace: node:internal/modules/cjs/...
Solution:
or move to a debian based image for example
Jump to solution
6 Replies
Neto
Neto8mo ago
the issue is related to alpine and the c bindings you either try go handle on the docker image
Solution
Neto
Neto8mo ago
or move to a debian based image for example
alan
alanOP8mo ago
thanks! I'll try chaning to a debian based image and report back. I was using an alpine based one per this example https://github.com/vercel/next.js/tree/canary/examples/with-docker
GitHub
next.js/examples/with-docker at canary · vercel/next.js
The React Framework. Contribute to vercel/next.js development by creating an account on GitHub.
Neto
Neto8mo ago
it's an issue with alpine and sqlite
alan
alanOP8mo ago
I think that may have helped, since I'm getting a new error!
41.87 Type error: Conversion of type 'Statement' to type 'DatabaseUser' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
41.87 Type 'Statement' is missing the following properties from type 'DatabaseUser': id, username, github_id
41.87
41.87 26 | });
41.87 27 | const githubUser: GitHubUser = await githubUserResponse.json();
41.87 > 28 | const existingUser = db
41.87 | ^
41.87 29 | .prepare('SELECT * FROM user WHERE github_id = ?')
41.87 30 | .get(githubUser.id) as DatabaseUser | undefined;
41.87 31 |
41.87 Type error: Conversion of type 'Statement' to type 'DatabaseUser' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
41.87 Type 'Statement' is missing the following properties from type 'DatabaseUser': id, username, github_id
41.87
41.87 26 | });
41.87 27 | const githubUser: GitHubUser = await githubUserResponse.json();
41.87 > 28 | const existingUser = db
41.87 | ^
41.87 29 | .prepare('SELECT * FROM user WHERE github_id = ?')
41.87 30 | .get(githubUser.id) as DatabaseUser | undefined;
41.87 31 |
this is weird that I'm only seeing this issue when building but not running in dev mode I just updated it and am now getting this error:
36.63 Error: The module '/app/node_modules/better-sqlite3/build/Release/better_sqlite3.node'
36.63 was compiled against a different Node.js version using
36.63 NODE_MODULE_VERSION 111. This version of Node.js requires
36.63 NODE_MODULE_VERSION 120. Please try re-compiling or re-installing
36.63 the module (for instance, using `npm rebuild` or `npm install`).
36.63 at Module._extensions..node (node:internal/modules/cjs/loader:1464:18)
36.63 at Module.load (node:internal/modules/cjs/loader:1205:32)
36.63 at Module._load (node:internal/modules/cjs/loader:1021:12)
36.63 at Module.require (node:internal/modules/cjs/loader:1230:19)
36.63 at mod.require (/app/node_modules/next/dist/server/require-hook.js:65:28)
36.63 at require (node:internal/modules/helpers:179:18)
36.63 at bindings (/app/node_modules/bindings/bindings.js:112:48)
36.63 at new Database (/app/node_modules/better-sqlite3/lib/database.js:48:64)
36.63 at Database (/app/node_modules/better-sqlite3/lib/database.js:11:10)
36.63 at 91070 (/app/.next/server/app/login/github/route.js:1:2375) {
36.63 code: 'ERR_DLOPEN_FAILED'
36.63 }
36.63 Error: The module '/app/node_modules/better-sqlite3/build/Release/better_sqlite3.node'
36.63 was compiled against a different Node.js version using
36.63 NODE_MODULE_VERSION 111. This version of Node.js requires
36.63 NODE_MODULE_VERSION 120. Please try re-compiling or re-installing
36.63 the module (for instance, using `npm rebuild` or `npm install`).
36.63 at Module._extensions..node (node:internal/modules/cjs/loader:1464:18)
36.63 at Module.load (node:internal/modules/cjs/loader:1205:32)
36.63 at Module._load (node:internal/modules/cjs/loader:1021:12)
36.63 at Module.require (node:internal/modules/cjs/loader:1230:19)
36.63 at mod.require (/app/node_modules/next/dist/server/require-hook.js:65:28)
36.63 at require (node:internal/modules/helpers:179:18)
36.63 at bindings (/app/node_modules/bindings/bindings.js:112:48)
36.63 at new Database (/app/node_modules/better-sqlite3/lib/database.js:48:64)
36.63 at Database (/app/node_modules/better-sqlite3/lib/database.js:11:10)
36.63 at 91070 (/app/.next/server/app/login/github/route.js:1:2375) {
36.63 code: 'ERR_DLOPEN_FAILED'
36.63 }
alan
alanOP8mo ago
the last issue was fixed by deleting node_modules and reinstalling it. Thanks again, @nyx (Rustular DevRel) !
Want results from more Discord servers?
Add your server