> @ 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.<anonymous> (/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 ELIFECYCLE
npm ERR! errno 1
npm ERR! @ start: `node app.js`
npm ERR! Exit status 1
npm 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```
在nodejs中使用kafka包用docker部署时会出现以上错误。
解决方法,按如下Dockerfile进行build即可:
FROM node:8.11
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY . /usr/src/app
RUN npm install
RUN npm install node-rdkafka --no-package-lock
CMD [ "npm", "start" ]
将node-rdkafka依赖从package.json中移出
然后单独执行:
RUN npm install node-rdkafka --no-package-lock
这样就可以了。