Skip to content

Installing node‐rdkafka on M1 mac

liranmauda edited this page Nov 6, 2024 · 1 revision

When trying to install node-rdkafka on M1 Mac we get The following error:

npm ERR!    15 | #include "rdkafkacpp.h"
npm ERR!       |          ^~~~~~~~~~~~~~
npm ERR! 1 error generated.

This is because for M1 chip, librdkafka is installed under /opt/homebrew/Cellar, and for Intel Mac, it's under /usr/local/Cellar.

For some reason, node-rdkafka assumes you're using an Intel chip and looks for rdkafkacpp.h under /usr/local/Cellar path, which is empty if you use an ARM terminal.

In order to resolve it:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

  • Install librdkafka for Intel: /usr/local/bin/brew install librdkafka
  • Go back to your ARM terminal, and try npm install again, it should be successful.

Credit: https://github.com/Blizzard/node-rdkafka/issues/937#issuecomment-1075915880

Clone this wiki locally