bun pm
命令组提供了一套用于 Bun 包管理器的实用工具。
pack
创建当前工作区的 tarball
bun pm pack
pack
命令的选项
--dry-run
: 执行所有任务,但不将 tarball 写入磁盘。--destination
: 指定保存 tarball 的目录。--filename
: 指定要保存的 tarball 的确切文件名。--ignore-scripts
: 跳过运行 pre/postpack 和 prepare 脚本。--gzip-level
: 设置 gzip 的自定义压缩级别,范围从 0 到 9(默认为 9)。
注意:--filename
和 --destination
不能同时使用
bin
打印本地项目的 bin
目录的路径
bun pm bin
/path/to/current/project/node_modules/.bin
打印全局 bin
目录的路径
bun pm bin -g
<$HOME>/.bun/bin
ls
打印当前项目中已安装依赖及其解析版本的列表,排除依赖项的依赖。
bun pm ls
/path/to/project node_modules (135)
├── eslint@8.38.0
├── react@18.2.0
├── react-dom@18.2.0
├── typescript@5.0.4
└── zod@3.21.4
打印所有已安装的依赖,包括 nth 级依赖。
bun pm ls --all
/path/to/project node_modules (135)
├── @eslint-community/eslint-utils@4.4.0
├── @eslint-community/regexpp@4.5.0
├── @eslint/eslintrc@2.0.2
├── @eslint/js@8.38.0
├── @nodelib/fs.scandir@2.1.5
├── @nodelib/fs.stat@2.0.5
├── @nodelib/fs.walk@1.2.8
├── acorn@8.8.2
├── acorn-jsx@5.3.2
├── ajv@6.12.6
├── ansi-regex@5.0.1
├── ...
whoami
打印你的 npm 用户名。需要你已登录 (bunx npm login
),凭据在 bunfig.toml
或 .npmrc
中。
bun pm whoami
hash
生成并打印当前 lockfile 的哈希值
bun pm hash
打印用于哈希 lockfile 的字符串
bun pm hash-string
打印存储在当前 lockfile 中的哈希值
bun pm hash-print
cache
打印 Bun 全局模块缓存的路径
bun pm cache
清除 Bun 全局模块缓存
bun pm cache rm
migrate
迁移另一个包管理器的 lockfile,无需安装任何内容
bun pm migrate
untrusted
打印当前带有脚本的未受信任的依赖项
bun pm untrusted
./node_modules/@biomejs/biome @1.8.3
» [postinstall]: node scripts/postinstall.js
These dependencies had their lifecycle scripts blocked during install.
trust
运行未受信任的依赖项的脚本并添加到 trustedDependencies
bun pm trust <names>
trust
命令的选项
--all
:信任所有未受信任的依赖项。
default-trusted
打印默认受信任的依赖项列表
bun pm default-trusted
在 GitHub 上查看当前列表 here