gyp: No Xcode or CLT version detected! | macOS 10.15 Catalina

最近在使用 npm install 的時候遇到一個問題,裝到一半會出現 gyp: No Xcode or CLT version detected! 會出現此問題是因為 node-gyp 沒有讀到 Xcode,那怎麼解決呢?

解決方法

重新安裝 command-line tools 

方法一

尋找 command-line tools

先找到 command-line tools 的位置使用指令 xcode-select --print-path 尋找,預設位置 /Library/Developer/CommandLineTools

clarence ~ xcode-select --print-path
/Library/Developer/CommandLineTools

移除 command-line tools

 clarence  ~  sudo rm -r -f /Library/Developer/CommandLineTools

重新安裝 command-line tools

clarence  ~  xcode-select --install

方法二

直接移除 command-line tools

clarence  ~  sudo rm -rf $(xcode-select -print-path)

重新安裝 command-line tools

clarence  ~  xcode-select --install

結論

每次更新系統好像都會發生,暫時還沒找到更好的解決方法 QQ