Taager’s Foray in Messaging Part 2; Installing the Pulsar Node.js client on macOS
Published in
2 min readApr 4, 2022
See if python is installed via the macOS installer. Run which python3
. If it returns a value similar to /Library/Frameworks/Python.framework/Versions/3.xx/bin/python3
, we can skip the next step.
Install Python3 via the macOS installer. The version installed via brew
does not seem to work correctly, probably because of the different locations of python installations.
Install dependencies
brew install openssl cmake
export OPENSSL_INCLUDE_DIR=/usr/local/opt/openssl/include/
export OPENSSL_ROOT_DIR=/usr/local/opt/openssl/
brew install protobuf boost boost-python3 log4cxx
Install Google Test
git clone https://github.com/google/googletest.git
cd googletest
cmake .
make install
- The third step
cmake .
, can possibly fail due toCould not find Boost Python Library
. If that happens, we can manually modify theCMakeLists.txt
file fromfind_package(PythonLibs REQUIRED)
tofind_package(PythonLibs 3 REQUIRED)
- If we encounter the error
Could NOT find PythonLibs: Found unsuitable version "X.X.X", but required is at least "3"
, we can manually update CMake to use the specific python version (from the macOS installer in the first step). Modifyingcmake
command to run like this (don’t forget the last period) should workcmake -DPYTHON_INCLUDE_DIR=${PYTHON_INCLUDE_DIR} -DPYTHON_LIBRARY=${PYTHON_LIBRARIES} .
Install Pulsar-Cpp Client
The pulsar cpp client does not have pre-built binaries for Node.js. So we have to build it ourselves!
git clone https://github.com/apache/pulsar
cd pulsar/pulsar-client-cpp
cmake .
make
Install the Node.js client
export CPLUS_INCLUDE_PATH="$(brew --prefix)/include"
export LIBRARY_PATH="$(brew --prefix)/lib"
npm install pulsar-client
- At the time of writing, the latest version of
pulsar-client
is not available onnpmjs
. If that happens, we can manually switch to the version1.6.0
. - If
node
is updated or if we need to rerunnpm istall
, the environment variables will have to be re-declared (or we can add them into our/.zshrc
script).