Blizzard / node-rdkafka

Node.js bindings for librdkafka
MIT License
2.12k stars 396 forks source link

invalid ELF header #944

Open mkscastillo opened 2 years ago

mkscastillo commented 2 years ago

Environment Information

Steps to Reproduce Getting this error when trying to start kafka feed

Additional context

2022-03-15 21:17:41,608 - app-ctop - INFO - stderr: /ctoc/app-ctop/node_modules/bindings/bindings.js:121
        throw e\;
        ^

Error: node_modules/node-rdkafka/build/Release/node-librdkafka.node: invalid ELF header
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:1144:18)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:93:18)
    at bindings (node_modules/bindings/bindings.js:112:48)
    at Object.<anonymous> (node_modules/node-rdkafka/librdkafka.js:10:32)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32) {
  code: 'ERR_DLOPEN_FAILED'
}

Also checked for:

 readelf -a node_modules/node-rdkafka/build/Release/node-librdkafka.node
readelf: /ctoc/app-ctop/node_modules/node-rdkafka/build/Release/node-librdkafka.node: Error: Not an ELF file - it has the wrong magic bytes at the start
donniekerr commented 2 years ago

getting similar error when running it on Azure Function with Linux OS with Node 16

Result: Failure Exception: Error: /home/site/wwwroot/node_modules/node-rdkafka/build/Release/node-librdkafka.node: invalid ELF header Stack: Error: /home/site/wwwroot/node_modules/node-rdkafka/build/Release/node-librdkafka.node: invalid ELF header at Object.Module._extensions..node (node:internal/modules/cjs/loader:1183:18) at Module.load (node:internal/modules/cjs/loader:981:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) at Module.require (node:internal/modules/cjs/loader:1005:19) at require (node:internal/modules/cjs/helpers:102:18) at bindings (/home/site/wwwroot/node_modules/bindings/bindings.js:112:48) at Object.<anonymous> (/home/site/wwwroot/node_modules/node-rdkafka/librdkafka.js:10:32) at Module._compile (node:internal/modules/cjs/loader:1101:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10) at Module.load (node:internal/modules/cjs/loader:981:32)

iAlex97 commented 2 years ago

node-rdkafka is binding against a C library which must be compiled against the architecture that is going to run on. Is it possible that you copied your local node_modules directory to Azure Function runtime?

tatianajiselle commented 2 years ago

agree with IAlex97 -- I have seen this error when my nvm version is not in sync with what the project is compiled against; the binaries need to match the version you are compiling with. ensure you are using the same node version before running npm install.