While attempting to use the better-sqlite3
package from NPM, I get an error saying “invalid ELF header”. I looked on the issue tracker for the package, and it said to delete the node_modules
folder and install again. I assume using the --nocache option does this, so I tried using that option and once it finished building successfully I still got the error. Another possible cause is that the better-sqlite3
package being built using balena push
is another architecture that makes it not work with my Raspberry Pi 400.
Hi there, could you share your dockerfile for this container? It might give us some clues as to what is happening.
Hi @jacob1, let us know if you managed to resolve this issue or not. If you could share a minimal version of your dockerfile that produces this error, we will take a further look.
I found another forum post where a user reported the same error and we resolved it after some back and forth discussion. Sharing in case it helps you with troubleshooting.
Cheers…
Hi - sorry to jump on this. I’m attempting to build a multicontainer system with sqlite3 container and a nodejs server with mounted volumes for data persistence. I have both containers running great, but when I run the server, it fails with the following error related to sqlite3 package, similar to jacob:
^
Error: /app/node_modules/sqlite3/build/Release/node_sqlite3.node: invalid ELF header
at Module._extensions..node (node:internal/modules/cjs/loader:1544:18)
at Module.load (node:internal/modules/cjs/loader:1249:32)
at Module._load (node:internal/modules/cjs/loader:1065:12)
at Module.require (node:internal/modules/cjs/loader:1271:19)
at require (node:internal/modules/helpers:123:16)
at bindings (/app/node_modules/bindings/bindings.js:112:48)
at Object.<anonymous> (/app/node_modules/sqlite3/lib/sqlite3-binding.js:1:37)
at Module._compile (node:internal/modules/cjs/loader:1434:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1518:10)
at Module.load (node:internal/modules/cjs/loader:1249:32) {
code: 'ERR_DLOPEN_FAILED'
}
Node.js v22.2.0
My dockerfile compose file is below:
services:
# tc04-gateway:
# build: ./tc04-gateway
# # restart: always
gateway-server:
build: ./gateway-server
# restart: always
network_mode: "host"
volumes:
- resin-data:/data
sqlite-container:
build: ./database
# image: alpine:latest
volumes:
- resin-data:/data
# command: sh -c "apk --no-cache add sqlite && cp /data/initial-db.sqlite /data/db.sqlite && sqlite3 /data/db.sqlite < /data/init.sql && tail -f /dev/null"
# container_name: sqlite-container
# restart: always
volumes:
resin-data:
Could someone suggest a way build for the right target (if that’s what this is?) or just generally debug this?
Thanks, Kristof