0

I am unable to install node-rdkafka in any of my projects recently by using

npm i node-rdkafka

or if I had a package-lock.json using

npm ci

this is the error I am getting with node 14 and npm 6.14.17 -

npm WARN read-shrinkwrap This version of npm is compatible with lockfileVersion@1, but package-lock.json was generated for lockfileVersion@2. I'll try to do my best with it!

> @newrelic/native-metrics@7.1.1 install /Users/subhrangshu/Documents/MyProject/node_modules/@newrelic/native-metrics
> node ./lib/pre-build.js install native_metrics

============================================================================
Attempting install in native-metrics module. Please note that this is an
OPTIONAL dependency, and any resultant errors in this process will not
affect the general performance of the New Relic agent, but event loop and
garbage collection metrics will not be collected.
============================================================================

> /Users/subhrangshu/.nvm/versions/node/v14.21.2/bin/node /Users/subhrangshu/.nvm/versions/node/v14.21.2/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js clean configure
> /Users/subhrangshu/.nvm/versions/node/v14.21.2/bin/node /Users/subhrangshu/.nvm/versions/node/v14.21.2/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build -j 4 native_metrics
  CXX(target) Release/obj.target/native_metrics/src/GCBinder.o
  CXX(target) Release/obj.target/native_metrics/src/native_metrics.o
  CXX(target) Release/obj.target/native_metrics/src/LoopChecker.o
  CXX(target) Release/obj.target/native_metrics/src/RUsageMeter.o
In file included from ../src/GCBinder.cpp:7:
../src/GCBinder.hpp:8:10: fatal error: map: No such file or directory
    8 | #include <map>
      |          ^~~~~
../src/LoopChecker.cpp:7:10: fatal error: algorithm: No such file or directory
    7 | #include <algorithm>
      |          ^~~~~~~~~~~
../src/RUsageMeter.cpp:7:10: fatal error: cstring: No such file or directory
    7 | #include <cstring>
      |          ^~~~~~~~~
compilation terminated.
compilation terminated.
compilation terminated.
make: *** [Release/obj.target/native_metrics/src/GCBinder.o] Error 1
make: *** Waiting for unfinished jobs....
make: *** [Release/obj.target/native_metrics/src/LoopChecker.o] Error 1
make: *** [Release/obj.target/native_metrics/src/RUsageMeter.o] Error 1
In file included from /Users/subhrangshu/Library/Caches/node-gyp/14.21.2/include/node/node.h:67,
                 from ../../../nan/nan.h:58,
                 from ../src/native_metrics.cpp:7:
/Users/subhrangshu/Library/Caches/node-gyp/14.21.2/include/node/v8.h:22:10: fatal error: memory: No such file or directory
   22 | #include <memory>
      |          ^~~~~~~~
compilation terminated.
make: *** [Release/obj.target/native_metrics/src/native_metrics.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/subhrangshu/.nvm/versions/node/v14.21.2/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (events.js:400:28)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:285:12)
gyp ERR! System Darwin 22.2.0
gyp ERR! command "/Users/subhrangshu/.nvm/versions/node/v14.21.2/bin/node" "/Users/subhrangshu/.nvm/versions/node/v14.21.2/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "-j" "4" "native_metrics"
gyp ERR! cwd /Users/subhrangshu/Documents/MyProject/node_modules/@newrelic/native-metrics
gyp ERR! node -v v14.21.2
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok 
Failed to execute native-metrics install: No pre-built artifacts for your OS/architecture.

> node-rdkafka@2.14.0 install /Users/subhrangshu/Documents/MyProject/node_modules/node-rdkafka
> node-gyp rebuild

  CXX(target) Release/obj.target/node-librdkafka/src/binding.o
../src/binding.cc:10:10: fatal error: iostream: No such file or directory
   10 | #include <iostream>
      |          ^~~~~~~~~~
compilation terminated.
make: *** [Release/obj.target/node-librdkafka/src/binding.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/subhrangshu/.nvm/versions/node/v14.21.2/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (events.js:400:28)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:285:12)
gyp ERR! System Darwin 22.2.0
gyp ERR! command "/Users/subhrangshu/.nvm/versions/node/v14.21.2/bin/node" "/Users/subhrangshu/.nvm/versions/node/v14.21.2/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/subhrangshu/Documents/MyProject/node_modules/node-rdkafka
gyp ERR! node -v v14.21.2
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok 
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @newrelic/native-metrics@7.1.1 (node_modules/@newrelic/native-metrics):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @newrelic/native-metrics@7.1.1 install: `node ./lib/pre-build.js install native_metrics`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-rdkafka@2.14.0 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the node-rdkafka@2.14.0 install 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!     /Users/subhrangshu/.npm/_logs/2023-01-13T04_21_16_920Z-debug.log

based on this question - GYP ERR! build error. stack Error: 'make' failed with exit code 2 and other similar articles -

  1. Have tried upgrading to macOS 13.1
  2. Tried installing using node 16, node 15, node 18 and node 14
  3. Removed the package-lock.json and node_modules folder and reinstalled using npm i instead.
  4. Removed and reinstalled xcode-select --install
  5. Even though the error shown is - it is unable to read c++ headers, have tried compiling a Hello World C++ program using g++ main.cpp -o main or make main and both compiled the program successfully
  6. Have updated and upgraded brew

Current versions - enter image description here

NUMBART
  • 52
  • 9
  • Try `sudo xcode-select --select` and select suitable dev tools. – 273K Jan 13 '23 at 04:57
  • @273K this command is giving - `xcode-select: error: invalid argument '--select' Usage: xcode-select [options] ` – NUMBART Jan 13 '23 at 05:06
  • My bad, it should be `--switch` or short `-s`. View available options `--print` or short `-p`. – 273K Jan 13 '23 at 05:20
  • `-p` shows the path as `/Applications/Xcode.app/Contents/Developer` how do I figure out what to change it to using the `-s` option? – NUMBART Jan 13 '23 at 05:31

0 Answers0