node-rdkafka icon indicating copy to clipboard operation
node-rdkafka copied to clipboard

invalid ELF header

Open mkscastillo opened this issue 2 years ago • 3 comments

Environment Information

  • OS [e.g. Mac, Arch, Windows 10]: RHEL 7
  • Node Version [e.g. 8.2.1]: v14.8.2
  • NPM Version [e.g. 5.4.2]: 6.14.15
  • node-rdkafka version [e.g. 2.3.3]: 2.7.4

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

mkscastillo avatar Mar 16 '22 02:03 mkscastillo

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)

donniekerr avatar Mar 16 '22 20:03 donniekerr

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?

iAlex97 avatar Apr 03 '22 16:04 iAlex97

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.

tatianajiselle avatar Apr 12 '22 21:04 tatianajiselle