LinuxCommandLibrary

bun-pm-ls

TLDR

List dependencies in the current project

$ bun pm [[ls|list]]
copy

List all transitive dependencies
$ bun pm [[ls|list]] [[-a|--all]]
copy

SYNOPSIS

bun pm ls [<flags>]

PARAMETERS

--all, -A
    Show all workspace packages in monorepos

--bun
    Explicitly use bun.lockb (default behavior)

--depth <number>
    Maximum dependency tree depth (default: unlimited)

--global
    List packages in global cache directory

--json
    Output as JSON

--no-dedupe
    Disable dependency deduplication

--parseable
    Tab-separated output for parsing

--workspace
    List all workspace packages

DESCRIPTION

The bun pm ls command displays the dependency tree of installed packages in a Bun-managed project. It reads from bun.lockb or node_modules, showing packages, versions, and their transitive dependencies in a tree-like format.

By default, it lists production dependencies but can include all with options. Output is human-readable, with indentation indicating depth and asterisks (*) marking extranous packages not in lockfile. It deduplicates shared dependencies automatically.

Ideal for inspecting installs, debugging version conflicts, or verifying resolutions. Supports monorepos via workspace options. JSON output enables scripting and tooling integration.

Unlike npm ls, Bun's version is faster due to optimized lockfile parsing and aims for npm compatibility while leveraging Bun's speed.

CAVEATS

May differ slightly from npm ls in monorepo handling; requires Bun installation.

EXIT CODES

0: success
1: invalid args or no lockfile

EXAMPLE OUTPUT

my-project@1.0.0 /path/to/project
└── react@18.2.0

JSON: bun pm ls --json yields array of package objects.

HISTORY

Introduced in Bun 0.5.0 (2023) as part of Bun's package manager for fast, compatible alternative to npm/yarn. Developed by Jarred Sumner; evolved with Bun releases for better npm parity.

SEE ALSO

npm(1), pnpm(1), yarn(1)

Copied to clipboard