LinuxCommandLibrary

bun-unlink

TLDR

Unregister the current package globally

$ bun unlink
copy

Unregister a package in a specific directory
$ bun unlink --cwd [path/to/package]
copy

Perform a dry run without actually unregistering
$ bun unlink --dry-run
copy

Display help
$ bun unlink [[-h|--help]]
copy

SYNOPSIS

bun unlink [<package_path>]

DESCRIPTION

bun unlink removes symbolic links created by bun link in Bun's global package cache. Bun is a fast JavaScript runtime, bundler, transpiler, and package manager built with JavaScriptCore and Zig, aiming to outperform Node.js and npm in speed.

The linking workflow enables local development: navigate to your package directory, run bun link to symlink it into ~/.bun/install/cache. Projects can then use this linked version via bun add without publishing to npm. After testing, bun unlink cleans up the symlink, restoring registry-sourced installs.

This command operates on the current directory's package by default or a specified path. It ensures no local symlinks interfere with production dependencies. Safe for repeated use; idempotent if not linked. Essential for workflows mirroring npm link but faster, leveraging Bun's disk and network optimizations.

Integrates with Bun's package.json handling, lockfile (bun.lockb), and node_modules structure, maintaining compatibility with npm ecosystems.

CAVEATS

Only removes Bun-created links; does not affect standard node_modules installs or other tools' links. Requires a package.json in the target directory.

EXAMPLE

cd ~/my-local-pkg
bun unlink

Removes link for current package.

bun unlink ../sibling-pkg

Unlinks specified path.

WORKFLOW

1. cd pkg && bun link
2. In project: bun add pkg
3. Test locally.
4. bun unlink in pkg dir.

HISTORY

Introduced in Bun v0.1.0 (September 2022) as part of the all-in-one toolkit by Jarred Sumner. Evolved with package manager improvements in v1.0+ for better npm compatibility.

SEE ALSO

bun(1), npm(1), yarn(1)

Copied to clipboard