I am trying to install node-rdkafka
using npm and seeing the below error
nvm
/Users/VMac/.nvm/versions/node/v10.16.3/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin/node-gyp: line 5: /usr/local/lib/node_modules/node-gyp/bin/node-gyp.js: No such file or directory
npm WARN kafka-log-parser@1.0.0 No repository field.
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! node-rdkafka@2.7.0 install: `node-gyp rebuild`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the node-rdkafka@2.7.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/VMac/.npm/_logs/2020-09-30T14_35_01_271Z-debug.log
When I try running installing node-gyp
using npm install -g node-gyp
and run node-gyp rebuild
, I see the below error
gyp info it worked if it ends with ok
gyp info using node-gyp@7.1.0
gyp info using node@10.16.3 | darwin | x64
gyp info find Python using Python version 3.8.3 found at "/usr/local/anaconda3/bin/python3"
gyp info spawn /usr/local/anaconda3/bin/python3
gyp info spawn args [ '/Users/VMac/.nvm/versions/node/v10.16.3/lib/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'make',
gyp info spawn args '-I',
gyp info spawn args '/Users/VMac/Documents/VMAC/Code/GIT/kafka-log-simulator/build/config.gypi',
gyp info spawn args '-I',
gyp info spawn args '/Users/VMac/.nvm/versions/node/v10.16.3/lib/node_modules/node-gyp/addon.gypi',
gyp info spawn args '-I',
gyp info spawn args '/Users/VMac/Library/Caches/node-gyp/10.16.3/include/node/common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=/Users/VMac/Library/Caches/node-gyp/10.16.3',
gyp info spawn args '-Dnode_gyp_dir=/Users/VMac/.nvm/versions/node/v10.16.3/lib/node_modules/node-gyp',
gyp info spawn args '-Dnode_lib_file=/Users/VMac/Library/Caches/node-gyp/10.16.3/<(target_arch)/node.lib',
gyp info spawn args '-Dmodule_root_dir=/Users/VMac/Documents/VMAC/Code/GIT/kafka-log-simulator',
gyp info spawn args '-Dnode_engine=v8',
gyp info spawn args '--depth=.',
gyp info spawn args '--no-parallel',
gyp info spawn args '--generator-output',
gyp info spawn args 'build',
gyp info spawn args '-Goutput_dir=.' ]
gyp: binding.gyp not found (cwd: /Users/VMac/Documents/VMAC/Code/GIT/kafka-log-simulator) while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack at ChildProcess.onCpExit (/Users/VMac/.nvm/versions/node/v10.16.3/lib/node_modules/node-gyp/lib/configure.js:351:16)
gyp ERR! stack at ChildProcess.emit (events.js:198:13)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)
gyp ERR! System Darwin 19.6.0
gyp ERR! command "/Users/VMac/.nvm/versions/node/v10.16.3/bin/node" "/Users/VMac/.nvm/versions/node/v10.16.3/bin/node-gyp" "rebuild"
gyp ERR! cwd /Users/VMac/Documents/VMAC/Code/GIT/kafka-log-simulator
gyp ERR! node -v v10.16.3
gyp ERR! node-gyp -v v7.1.0
gyp ERR! not ok
I also tried xcode-select --install
but no luck.
Any suggestions on how to fix this and successfully install node-rdkafka
using npm on my mac?
After trying various options online, I couldn't find the right solution. So, this is what I did and worked
Uninstalled node
following the instructions here
If you are using Homebrew
, run
brew uninstall node
Use --force
or --ignore-dependencies
if required
Run node -v
. If you still see the version info, follow the instructions here
I also wanted to remove nvm
from my machine. So, I removed the ~/.nvm
folder. But, I am still seeing the nvm version. To completely clean-up, remove references from ~/.bashrc
and ~/.zshrc
if any
I realised that I had two versions of node
Post this, I only installed nvm
(Don't install node or npm).
brew install nvm
and then installed the required version of node and npm using
nvm install <NODE_VERSION>
This solved my node-gyp
errors