LinuxCommandLibrary

bun-link

Link local packages for development

TLDR

Link the current package globally

$ bun link
copy

Link a package locally to a project
$ bun link [package_name]
copy

Link a package in a specific directory
$ bun link --cwd [path/to/package]
copy

Perform a dry run without actually linking
$ bun link --dry-run
copy

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

SYNOPSIS

bun link [<path>] [--force]

PARAMETERS

<path>
    Optional path to package directory (defaults to current directory)

--force
    Overwrite existing link for the same package name

DESCRIPTION

bun link is a command from the Bun JavaScript runtime and package manager, designed for fast development workflows. It creates a symlink in Bun's global link registry pointing to a local package directory. This allows other Bun projects to install and use the local package version via its package.json name, bypassing remote registries like npm.

Usage is simple: navigate to a package directory with a valid package.json, then run bun link. The package becomes available globally under its name. In another project, execute bun add <package-name> to link the local version. Changes in the source directory are immediately reflected.

Ideal for monorepos or cross-project development, it mirrors npm link but leverages Bun's speed and cache. Use bun unlink to remove links. Supports linking remote paths for flexibility.

CAVEATS

Links are Bun-specific and stored in Bun's cache (~/.bun/install/cache). Incompatible with npm/yarn/pnpm. Package names must be unique to avoid conflicts.
Does not publish to registries; use bun unlink for cleanup.

EXAMPLE

cd ~/my-local-pkg
bun link

In new project:
bun add my-local-pkg
bun run # uses linked version

UNLINKING

bun unlink [<pkg-name>] removes the global link.

HISTORY

Introduced in Bun 0.5.0 (early 2023) by Jarred Sumner and Oven team. Evolved with Bun 1.0 stable release (Sep 2024), enhancing JavaScript bundling speed over Node.js equivalents.

SEE ALSO

ln(1), bun(1)

Copied to clipboard