Skip to main content
Link a local package globally or use a globally-linked package.

Behavior

bun link has two modes:

Register a package (no arguments)

Run bun link in a package directory to register it globally:
This creates a global link that other projects can reference.

Use a linked package

Run bun link <package> in another project to use the globally-linked package:
This creates a symlink in node_modules pointing to the globally-linked package. Globally-linked packages are stored in:
  • macOS/Linux: ~/.bun/install/global/node_modules
  • Windows: %USERPROFILE%\.bun\install\global\node_modules

Examples

Use a linked package in another project

Now my-app can import from my-utils:
Changes in my-utils are immediately reflected in my-app (no rebuild needed).
You can also use link: protocol directly in package.json:
Then run:
Alternatively, use relative paths with file: protocol:

Binaries

If a linked package has a bin field, the binary is linked to the global bin directory:
After bun link, the my-cli command is available globally:

Flags

--cwd <path>

Run command in specified directory.

--global-dir <path>

Use a custom global directory.

Unlinking packages

To remove a global link:
To remove a linked package from a project:
See bun unlink for details. bun link works similarly to npm link but with some differences:

Common issues

Package not found

If bun link <package> fails with “not found”, ensure the package is registered:

Changes not reflected

If changes in the linked package aren’t reflected:
  1. Ensure you’re using a symlink (check node_modules/package)
  2. Restart your development server
  3. For TypeScript, rebuild the linked package

Use cases

Local development

Develop a library and application simultaneously:

Monorepos

For monorepos, consider using workspaces instead of bun link.

Testing unpublished packages

Test a package before publishing: