Skip to main content
在本地目录中使用 bun link 将当前包注册为”可链接”包。
terminal
现在,可以使用 bun link cool-pkg 将此包”链接”到其他项目中,这会在目标项目的 node_modules 目录中创建一个指向本地目录的符号链接。
terminal
--save 标志还会将 cool-pkg 添加到应用的 package.jsondependencies 字段中,版本说明符会告诉 Bun 从注册的本地目录加载,而不是从 npm 安装:
package.json

取消链接

在根目录中使用 bun unlink 来取消注册本地包。
terminal

CLI 用法

安装范围

--global
boolean
全局安装。别名:-g

依赖管理

--production
boolean
不安装 devDependencies。别名:-p
--omit
string
从安装中排除 devoptionalpeer 依赖

项目文件与 Lockfile

--yarn
boolean
写入 yarn.lock 文件(yarn v1)。别名:-y
--frozen-lockfile
boolean
禁止更改 lockfile
--save-text-lockfile
boolean
保存基于文本的 lockfile
--lockfile-only
boolean
仅生成 lockfile,不安装依赖
--no-save
boolean
不更新 package.json 或不保存 lockfile
--save
boolean
default:"true"
保存到 package.json
--trust
boolean
添加到项目 package.jsontrustedDependencies 中并安装该包

安装控制

--force
boolean
始终从注册表请求最新版本并重新安装所有依赖。别名:-f
--no-verify
boolean
跳过验证新下载包的完整性
--backend
string
default:"clonefile"
安装依赖的特定平台优化。可选:clonefilehardlinksymlinkcopyfile
--linker
string
链接器策略(isolatedhoisted 之一)
--dry-run
boolean
不实际安装任何内容
--ignore-scripts
boolean
跳过项目 package.json 中的生命周期脚本(依赖的脚本从不运行)

网络与注册表

--ca
string
提供证书颁发机构签名证书
--cafile
string
—ca 相同,但指定证书的文件路径
--registry
string
使用特定注册表,覆盖 .npmrcbunfig.toml 和环境变量
--network-concurrency
number
default:"48"
最大并发网络请求数

性能与资源

--concurrent-scripts
number
生命周期脚本的最大并发作业数(默认:2 倍 CPU 核心数)

缓存

--cache-dir
string
从特定目录路径存储和加载缓存数据
--no-cache
boolean
完全忽略清单缓存

输出与日志

--silent
boolean
不输出任何日志
--quiet
boolean
打包时仅显示 tarball 名称
--verbose
boolean
极度详细的日志输出
--no-progress
boolean
禁用进度条
--no-summary
boolean
不打印摘要

平台目标

--cpu
string
覆盖可选依赖的 CPU 架构(例如 x64arm64* 表示全部)
--os
string
覆盖可选依赖的操作系统(例如 linuxdarwin* 表示全部)

全局配置与上下文

--config
string
指定配置文件路径(bunfig.toml)。别名:-c
--cwd
string
设置特定的当前工作目录

帮助

--help
boolean
打印此帮助菜单。别名:-h