Bun

全球快取

從註冊表下載的所有套件都儲存在 ~/.bun/install/cache 的全球快取中。它們儲存在命名為 ${name}@${version} 的子目錄中,因此可以快取套件的多個版本。

[install.cache]
# the directory to use for the cache
dir = "~/.bun/install/cache"

# when true, don't load from the global cache.
# Bun may still write to node_modules/.cache
disable = false

# when true, always resolve the latest versions from the registry
disableManifest = false

查看詳細資訊

最小化重新下載

Bun 致力於避免多次重新下載套件。在安裝套件時,如果快取中已包含 package.json 指定範圍內的版本,Bun 將使用快取的套件,而不是再次下載它。

安裝詳細資訊

快速複製

一旦套件下載到快取中,Bun 仍需要將這些檔案複製到 node_modules。Bun 使用最快的系統呼叫來執行這項任務。在 Linux 上,它使用硬連結;在 macOS 上,它使用 clonefile

節省磁碟空間

由於 Bun 使用硬連結將模組「複製」到 Linux 上專案的 node_modules 目錄中,因此套件的內容只存在於磁碟上的單一位置,大幅減少專用於 node_modules 的磁碟空間量。

此優點也適用於 macOS,但有例外。它使用寫入時複製的 clonefile,表示它不會佔用磁碟空間,但會計入磁碟機的限制。如果某些東西嘗試修補 node_modules/*,這種行為很有用,因此不可能影響其他安裝。

安裝策略