2020/08/23

[macOS] Mac 解決 gyp: No Xcode or CLT version detected! 的問題

環境

  • macOS Catalina 版本 10.15.6
  • Node v14.5.0
  • npm v6.14.5

問題

最近換新電腦,在開新專案執行 npm install 時出現下列訊息

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

解決方法

參考此文:Installation notes for macOS Catalina (v10.15)

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

執行過程它會重新安裝 command line tools

完成安裝後就行了

參考連結中還有其他指令,但我僅執行這行就成功了,若有朋友也遇到相同問題,可以參考接下來的動作

xcode-select --install

2020/08/05

[.NET Core] 如何移除不需要的 .NET Core SDK 版本

前言

開發環境日積月累,安裝了不少 SDK 版本,用不到也很佔空間,於是到了該清理的時候

目前我的機器存在的版本

Environment

  • Windows 10

安裝 dotnet-core-unistall 工具

  • 下載 msi 檔案: https://github.com/dotnet/cli-lab/releases
  • .NET Core Uninstall Tool 文件: https://aka.ms/dotnet-core-uninstall-docs
  • DotNet Core Uninstall v1.1.122401

安裝完 .NET Core Uninstall Tool 後,開啟 PowerShell 切換到 C:\Program Files (x86)\dotnet-core-uninstall 目錄

cd "C:\Program Files (x86)\dotnet-core-uninstall"

列出可移除的 dotnet core 版本

.\dotnet-core-uninstall list

有被 Visual Studio 使用的版本也會標記出來,這部分我要保留版本號的資訊

dry-run / whatif

在實際移除前,可用 dry-run 或 whatif 來看一下執行後會移除的版本

.\dotnet-core-uninstall dry-run [option] [VERSION]

.\dotnet-core-uninstall whatif [option] [VERSION]

移除僅特定版本 SDK

移除除了指定版本外的 SDK

把 dry-run 或 whatif 改成 remove 則會真的執行移除動作 (PowerShell 需使用系統管理員身分執行)

因為我要移除掉 Visual Studio 有使用以外的版本所以列出要保留的版本號,並加上 --all-but 的選項

.\dotnet-core-uninstall remove --sdk --all-but 2.1.202 2.1.513 2.1.802 2.2.104

刪除版本之前,也會再詢問是否確定要移除,執行後就會列出一個個被移除的版本

清掉之後僅留下的 SDK 版本

重新釋放掉不少空間

References