Macでyarn installしたらnode-gypのエラーが出た


どうした

既存のプロジェクトの手直しをしようとして、ローカルにnode_modulesを入れたかったので以下のコマンドを実行したらエラーが出た。

yarn
//yarn install の短縮形

エラーは以下。

Command: node-gyp rebuild
Arguments: 
Directory: /Users/user/.ghq/github.com/hppRC/gatsby-firebase-sample/node_modules/fsevents
Output:
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | darwin | x64
gyp info find Python using Python version 2.7.16 found at \"/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python\"
gyp info spawn /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
gyp info spawn args [
gyp info spawn args   '/usr/local/Cellar/node/13.2.0/libexec/lib/node_modules/npm/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/user/.ghq/github.com/hppRC/gatsby-firebase-sample/node_modules/fsevents/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/usr/local/Cellar/node/13.2.0/libexec/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/user/Library/Caches/node-gyp/13.2.0/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/user/Library/Caches/node-gyp/13.2.0',
gyp info spawn args   '-Dnode_gyp_dir=/usr/local/Cellar/node/13.2.0/libexec/lib/node_modules/npm/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/Users/user/Library/Caches/node-gyp/13.2.0/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/Users/user/.ghq/github.com/hppRC/gatsby-firebase-sample/node_modules/fsevents',
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 info spawn args ]
No receipt for 'com.apple.pkg.CLTools_Executables' found at '/'.

No receipt for 'com.apple.pkg.DeveloperToolsCLILeo' found at '/'.

No receipt for 'com.apple.pkg.DeveloperToolsCLI' found at '/'.

gyp: No Xcode or CLT version detected!
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/local/Cellar/node/13.2.0/libexec/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:351:16)
gyp ERR! stack     at ChildProcess.emit (events.js:210:5)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:270:12)
gyp ERR! System Darwin 19.2.0
gyp ERR! command \"/usr/local/Cellar/node/13.2.0/bin/node\" \"/usr/local/Cellar/node/13.2.0/libexec/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js\" \"rebuild\"
gyp ERR! cwd /Users/user/.ghq/github.com/hppRC/gatsby-firebase-sample/node_modules/fsevents

前までは普通にできとったやんけ!と思いつつ解決法を探して彷徨ったので記録しておく。

2020/02/15 追記

書いてあるやんけ...😇

下から9行目

gyp: No Xcode or CLT version detected!

環境

  • ProductName: Mac OS X
  • ProductVersion: 10.15.2
  • BuildVersion: 19C57
  • node: 13.5.0
  • npm: 6.13.4

It works for me!

まずこのコマンドを実行して、何も出力がないことを確認して欲しい。

pkgutil --packages | grep CL

出力が存在しないことを確認したら、ターミナルで以下のコマンドを実行して、MacのCommand Line toolsを再インストールしたところ、エラーが解決したことが確認できた。

yarn cache clean
sudo rm -rf $(xcode-select -print-path)
xcode-select --install

xcodeを入れ直すと解決するようだ。

もしこの方法で解決しなければ、このGitHubのIssueが参考になるので漁って見て欲しい。

まとめ

もっと親切なメッセージを出してくれ頼む(たのむ)