Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to solve the failure of node-rdkafka in docker build

Shulou Source: shulou.com Published: 2022-06-01 06:56:43 09月14日 Update

How to solve node-rdkafka failure in docker build, I believe many inexperienced people are helpless about this, for this reason this article summarizes the causes and solutions of the problem, through this article I hope you can solve this problem.

> @ start /> node app.js/node_modules/bindings/bindings.js:88 throw e ^Error: /node_modules/node-rdkafka/build/Release/node-librdkafka.node: invalid ELF header at Object.Module._ extensions.. node (module.js:664:18) at Module.load (module.js:554:32) at tryModuleLoad (module.js:497:12) at Function.Module._ load (module.js:489:3) at Module.require (module.js:579:17) at require (internal/module.js:11:18) at bindings (/node_modules/bindings/bindings.js:81:44) at Object. (/node_modules/node-rdkafka/librdkafka.js:10:32) at Module._ compile (module.js:635:30) at Object.Module._ extensions.. js (module.js:646:10)npm ERR! code ELIFECYCLEnpm ERR! errno 1npm ERR! @ start: `node app.js`npm ERR! Exit status 1npm ERR! npm ERR! Failed at the @ start script.npm ERR! This is probably not a problem with npm. There is likely additional logging output above.npm ERR! A complete log of this run can be found in:npm ERR! /root/.npm/_logs/2018-04-01T14_49_31_971Z-debug.log```

The above error occurs when deploying docker with kafka package in nodejs.

The solution is to build Dockerfile as follows:

FROM node:8.11RUN mkdir -p /usr/src/appWORKDIR /usr/src/appCOPY . /usr/src/appRUN npm installRUN npm install node-rdkafka --no-package-lockCMD [ "npm", "start" ]

Remove node-rdkafka dependency from package.json

Then separately:

RUN npm install node-rdkafka --no-package-lock

That'll do.

After reading the above, do you know how to solve node-rdkafka failure in docker build? If you still want to learn more skills or want to know more related content, welcome to pay attention to the industry information channel, thank you for reading!

Tags: Methods content more problems helpless for this reason skills articles experience industry information information channels errors channels Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Huawei MySQL Redmi Shulou Technology