我的nodejs应用程序需要kafka-streams库。据我所知,只有“kafka-streams”包支持构建在“node-rdkafka”包之上的kafka-streams。 因此,在成功安装后尝试运行 kafka-streams 时,会弹出错误,要求我先安装 node-rdkafka。因此,现在尝试安装node-rdkafka,但我面临着node-gyp重建的问题。
下面是我运行命令时的确切错误
sudo npm install node-rdkafka
我当前的版本:
node - v16.19.0
npm - 8.19.3
node-gyp - v9.4.0
错误:
(base) n0p03px@m-c02f914ymd6n Kafka-Processor % sudo npm install node-rdkafka
npm WARN old lockfile
npm WARN old lockfile The package-lock.json file was created with an old version of npm,
npm WARN old lockfile so supplemental metadata must be fetched from the registry.
npm WARN old lockfile
npm WARN old lockfile This is a one-time fix-up, please be patient...
npm WARN old lockfile
npm ERR! code 1
npm ERR! path /Users/n0p03px/Documents/My_Projects (new)/Kafka-Processor/node_modules/node-rdkafka
npm ERR! command failed
npm ERR! command sh -c -- node-gyp rebuild
npm ERR! ACTION deps_librdkafka_gyp_librdkafka_target_configure deps/librdkafka/config.h
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | darwin | x64
npm ERR! gyp info find Python using Python version 3.9.6 found at "/Applications/Xcode.app/Contents/Developer/usr/bin/python3"
npm ERR! gyp http GET https://nodejs.org/download/release/v16.19.0/node-v16.19.0-headers.tar.gz
npm ERR! gyp http 200 https://nodejs.org/download/release/v16.19.0/node-v16.19.0-headers.tar.gz
npm ERR! gyp http GET https://nodejs.org/download/release/v16.19.0/SHASUMS256.txt
npm ERR! gyp http 200 https://nodejs.org/download/release/v16.19.0/SHASUMS256.txt
npm ERR! gyp info spawn /Applications/Xcode.app/Contents/Developer/usr/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args '/Users/n0p03px/.nvm/versions/node/v16.19.0/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args 'binding.gyp',
npm ERR! gyp info spawn args '-f',
npm ERR! gyp info spawn args 'make',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/Users/n0p03px/Documents/My_Projects (new)/Kafka-Processor/node_modules/node-rdkafka/build/config.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/Users/n0p03px/.nvm/versions/node/v16.19.0/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/Users/n0p03px/Library/Caches/node-gyp/16.19.0/include/node/common.gypi',
npm ERR! gyp info spawn args '-Dlibrary=shared_library',
npm ERR! gyp info spawn args '-Dvisibility=default',
npm ERR! gyp info spawn args '-Dnode_root_dir=/Users/n0p03px/Library/Caches/node-gyp/16.19.0',
npm ERR! gyp info spawn args '-Dnode_gyp_dir=/Users/n0p03px/.nvm/versions/node/v16.19.0/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args '-Dnode_lib_file=/Users/n0p03px/Library/Caches/node-gyp/16.19.0/<(target_arch)/node.lib',
npm ERR! gyp info spawn args '-Dmodule_root_dir=/Users/n0p03px/Documents/My_Projects (new)/Kafka-Processor/node_modules/node-rdkafka',
npm ERR! gyp info spawn args '-Dnode_engine=v8',
npm ERR! gyp info spawn args '--depth=.',
npm ERR! gyp info spawn args '--no-parallel',
npm ERR! gyp info spawn args '--generator-output',
npm ERR! gyp info spawn args 'build',
npm ERR! gyp info spawn args '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp info spawn make
npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
npm ERR! /bin/sh: -c: line 0: syntax error near unexpected token `('
npm ERR! /bin/sh: -c: line 0: `LD_LIBRARY_PATH=/Users/n0p03px/Documents/My_Projects (new)/Kafka-Processor/node_modules/node-rdkafka/build/Release/lib.host:/Users/n0p03px/Documents/My_Projects (new)/Kafka-Processor/node_modules/node-rdkafka/build/Release/lib.target:$LD_LIBRARY_PATH; export LD_LIBRARY_PATH; cd ../deps; mkdir -p librdkafka; node ../util/configure'
npm ERR! make: *** [deps/librdkafka/config.h] Error 2
npm ERR! gyp ERR! build error
npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2
npm ERR! gyp ERR! stack at ChildProcess.onExit (/Users/n0p03px/.nvm/versions/node/v16.19.0/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:201:23)
npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:513:28)
npm ERR! gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:293:12)
npm ERR! gyp ERR! System Darwin 22.6.0
npm ERR! gyp ERR! command "/Users/n0p03px/.nvm/versions/node/v16.19.0/bin/node" "/Users/n0p03px/.nvm/versions/node/v16.19.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd /Users/n0p03px/Documents/My_Projects (new)/Kafka-Processor/node_modules/node-rdkafka
npm ERR! gyp ERR! node -v v16.19.0
npm ERR! gyp ERR! node-gyp -v v9.1.0
npm ERR! gyp ERR! not ok
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/n0p03px/.npm/_logs/2023-10-23T07_40_56_421Z-debug-0.log
(我确实尝试过使用多个节点和节点-gyp 版本组合,但没有运气。)
我也有同样的问题,有解决办法吗?