我正在尝试使用npm安装node-rdkafka
并看到以下错误
nvm
尝试了10.16.3(8.x,12.x和13.x)/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
当我尝试使用node-gyp
运行npm install -g node-gyp
安装node-gyp rebuild
并运行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
时,看到以下错误
xcode-select --install
我也尝试过node-rdkafka
,但是没有运气。
关于如何解决此问题并在Mac上使用npm成功安装variables:
OUTPUT_FILE_PATH: '$CI_PROJECT_DIR/bin/Release/netcoreapp3.1/MyTTL.zip'
- dotnet lambda package
- aws s3 cp $OUTPUT_FILE_PATH s3://$S3_BUCKET/MyTTL${CI_COMMIT_SHORT_SHA }.zip
的任何建议?
答案 0 :(得分:0)
在线尝试各种选项后,我找不到正确的解决方案。所以,这就是我所做的工作
按照说明here
卸载node
如果您使用的是Homebrew
,请运行
brew uninstall node
根据需要使用--force
或--ignore-dependencies
运行node -v
。如果仍然看到版本信息,请按照说明here
我还想从计算机中删除nvm
。因此,我删除了~/.nvm
文件夹。但是,我仍然看到nvm版本。要彻底清理,请从~/.bashrc
和~/.zshrc
中删除引用(如果有的话)
我意识到我有两个版本的节点
发布此信息后,我仅安装了nvm
(未安装节点或npm)。
brew install nvm
,然后使用
安装所需的node和npm版本nvm install <NODE_VERSION>
这解决了我的node-gyp
错误
答案 1 :(得分:0)
这对我有用:
“从https://developer.apple.com/download/more/为您的Catalina版本下载相应版本的“ Xcode命令行工具”。从MacOS 10.15.5开始,这就是Command_Line_Tools_for_Xcode_11.5.dmg”
答案 2 :(得分:0)
我自己遇到此问题并尝试了两个答案中提出的解决方案都没有成功,这对我来说是有用的,而无需卸载节点。
TL:DR
sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install
npm install node-rdkafka
此后,我就可以毫无问题地安装node-rdkafka
。
我不得不按照建议here删除CommandLineTools并重新安装它,因为当我尝试运行xcode-select --install
时,我会得到
xcode-select:错误:命令行工具已经安装,请使用“软件更新”来安装更新