Skip to content

NOTE

Bun v1.1.39 引入了 `bun.lock`,一種 JSONC 格式的鎖文件。`bun.lock` 是人類可讀的,無需配置即可進行 git diff,且不會影響性能。在 1.2.0+ 版本中,它是新項目使用的默認格式。[**了解更多。**](/zh-cn/pm/lockfile#text-based-lockfile)

使用 --yarn 標志生成 Yarn 兼容的 yarn.lock 文件(除了 bun.lock{b} 之外)。

sh
bun install --yarn

要將此設置為默認行為,請將以下內容添加到你的 bunfig.toml 文件中。

toml
[install.lockfile]
print = "yarn"

要將 Yarn 鎖文件打印到控制台而不寫入磁盤,請使用 bun "運行" 你的 bun.lockb

sh
bun bun.lockb
txt
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
# bun ./bun.lockb --hash: 9BFBF11D86084AAB-9418b03ff880c569-390CE6459EACEC9A...

abab@^2.0.6:
  version "2.0.6"
  resolved "https://registry.npmjs.org/abab/-/abab-2.0.6.tgz"
  integrity sha512-j2afSsaIENvHZN2B8GOpF566vZ5WVk5opAiMTvWgaQT8DkbOqsTfvNAvH...

請參閱 文檔 > 包管理器 獲取 Bun 包管理器的完整文檔。

Bun學習網由www.bunjs.com.cn整理維護