Repository navigation
Unable to do Cross-Platform compilation #1815
Description
Issue Summary
I've been testing my application with MacOS, but when I try to deploy my application in a cloud function which is running on linux and x64 architecture I'm getting the invalid ELF header error.
I've tried the following
- Installing with
--os linux --cpu x64options - Rebuild with
--os linux --cpu x64options - Installing with
--build-from-source --os linux --cpu x64options
but there's seems to be no change. Even when I try to test the application after running the above install/rebuild commands the application works fine in local machine (MacOS), and when I deploy the same to cloud functions it doesn't work and throws the invalid ELF header error.
The same works perfectly fine when I install the sqlite3 package from a linux machine and deploy it to the cloud function.
Am I missing something here when trying to install the package specific to an OS ?
Relevant logs or output
Error: /catalyst/node_modules/sqlite3/build/Release/node_sqlite3.node: invalid ELF header
at Module._extensions..node (node:internal/modules/cjs/loader:1454:18)
at Module.load (node:internal/modules/cjs/loader:1208:32)
at Module._load (node:internal/modules/cjs/loader:1024:12)
at Module.require (node:internal/modules/cjs/loader:1233:19)
at require (node:internal/modules/helpers:179:18)
at bindings (/catalyst/node_modules/bindings/bindings.js:112:48)
at Object. (/catalyst/node_modules/sqlite3/lib/sqlite3-binding.js:1:37)
at Module._compile (node:internal/modules/cjs/loader:1358:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)
at Module.load (node:internal/modules/cjs/loader:1208:32)
at Module._load (node:internal/modules/cjs/loader:1024:12)
at Module.require (node:internal/modules/cjs/loader:1233:19)
at require (node:internal/modules/helpers:179:18)
at Object. (/catalyst/node_modules/sqlite3/lib/sqlite3.js:2:17)
at Module._compile (node:internal/modules/cjs/loader:1358:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)
at Module.load (node:internal/modules/cjs/loader:1208:32)
at Module._load (node:internal/modules/cjs/loader:1024:12)
at Module.require (node:internal/modules/cjs/loader:1233:19)
at require (node:internal/modules/helpers:179:18)
at Object. (/catalyst/sql-test.js:1:17)
at Module._compile (node:internal/modules/cjs/loader:1358:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)
at Module.load (node:internal/modules/cjs/loader:1208:32)
at Module._load (node:internal/modules/cjs/loader:1024:12)
at Module.require (node:internal/modules/cjs/loader:1233:19)
at require (node:internal/modules/helpers:179:18)
at Object. (/catalyst/index.js:4:20)
at Module._compile (node:internal/modules/cjs/loader:1358:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)
at Module.load (node:internal/modules/cjs/loader:1208:32)
at Module._load (node:internal/modules/cjs/loader:1024:12)
at cjsLoader (node:internal/modules/esm/translators:348:17)
at ModuleWrap. (node:internal/modules/esm/translators:297:7)
at ModuleJob.run (node:internal/modules/esm/module_job:222:25)
at async ModuleLoader.import (node:internal/modules/esm/loader:316:24)
at async FlavourHandler.loadCustomerCode (file:///var/runtime/flavours/index.js:71:46)
at async CUSTOMER_ROUTE (file:///var/runtime/index.js:110:13) {
code: 'ERR_DLOPEN_FAILED'
}
Version
5.1.7
Node.js Version
v20.16.0
How did you install the library?
npm install
Activity
YasharF commentedon Apr 26, 2025
Try switching off of this package to NodeJS 22's new built-in/native SQLite support. The feature in NodeJS is experimental, but it is being actively maintained and pretty much each new update of node is having some improvements over the last. As an experimental support, it currently exposes some of the SQLite features, so it may or may not work in your use case. But in case if it does, you can drop this dependency and have much better maintenance.