J'essaie d'installer node-rdkafka
utilisant npm et node-rdkafka
vois l'erreur ci-dessous
nvm
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
Lorsque j'essaye d'exécuter l'installation de node-gyp
utilisant npm install -g node-gyp
et d'exécuter node-gyp rebuild
, je vois l'erreur ci-dessous
/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
J'ai aussi essayé xcode-select --install
mais pas de chance. Des suggestions sur la façon de résoudre ce problème et d'installer avec succès node-rdkafka
aide de npm sur mon Mac?
3 Réponses :
Après avoir essayé diverses options en ligne, je n'ai pas trouvé la bonne solution. Alors, c'est ce que j'ai fait et travaillé
node
désinstallé en suivant les instructions ici
Si vous utilisez Homebrew
, exécutez
nvm install <NODE_VERSION>
Utilisez --force
ou --ignore-dependencies
si nécessaire
Exécutez le node -v
. Si vous voyez toujours les informations de version, suivez les instructions ici
Je voulais aussi supprimer nvm
de ma machine. J'ai donc supprimé le dossier ~/.nvm
. Mais, je vois toujours la version nvm. Pour nettoyer complètement, supprimez les références de ~/.bashrc
et ~/.zshrc
cas échéant
J'ai réalisé que j'avais deux versions de node
Postez ceci, je n'ai installé que nvm
(n'installez pas de nœud ou de npm).
brew install nvm
puis installé la version requise de node et npm en utilisant
brew uninstall node
Cela a résolu mes erreurs node-gyp
C'est ce qui a fonctionné pour moi:
"Téléchargez la version appropriée des" Outils de ligne de commande pour Xcode "pour votre version de Catalina sur https://developer.apple.com/download/more/ . À partir de MacOS 10.15.5, il s'agit de Command_Line_Tools_for_Xcode_11.5.dmg"
Après avoir rencontré ce problème moi-même et essayé les solutions proposées dans les deux réponses sans succès, c'est ce qui a fonctionné pour moi, sans qu'il soit nécessaire de désinstaller node.
TL: DR
sudo rm -rf /Library/Developer/CommandLineTools xcode-select --install npm install node-rdkafka
Après cela, j'ai pu installer node-rdkafka
sans aucun problème.
J'ai dû supprimer CommandLineTools et le réinstaller, comme suggéré ici , car lorsque j'essayais d'exécuter xcode-select --install
le
xcode-select: erreur: les outils de ligne de commande sont déjà installés, utilisez "Software Update" pour installer les mises à jour