> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/zhcndoc/bun/llms.txt
> Use this file to discover all available pages before exploring further.

# bun unlink

Remove a globally-linked package.

```bash theme={null}
bun unlink
```

## Behavior

`bun unlink` removes a package from the global link registry.

### Unlink current package

Run `bun unlink` (no arguments) in a package directory to remove its global registration:

```bash theme={null}
cd ~/projects/my-library
bun unlink
```

This removes the global link so other projects can no longer link to it.

## Examples

### Unlink a package

```bash theme={null}
$ cd ~/projects/my-utils
$ bun unlink
bun unlink v1.0.0

success: unlinked package "my-utils"
```

The package is removed from the global registry. Other projects using `bun link my-utils` will no longer work until the package is re-linked.

### What gets removed

When unlinking a package, Bun:

1. Removes the symlink from global node\_modules
2. Removes any global bin links
3. Leaves existing project links intact

### Remove from a project

To remove a linked package from a specific project (without unlinking globally), use `bun remove`:

```bash theme={null}
cd ~/projects/my-app
bun remove my-utils
```

## Flags

### `--cwd <path>`

Run command in specified directory.

```bash theme={null}
bun unlink --cwd ~/projects/my-library
```

### `--global-dir <path>`

Use a custom global directory.

```bash theme={null}
bun unlink --global-dir /custom/path
```

## Re-linking

To re-link a package after unlinking:

```bash theme={null}
cd ~/projects/my-library
bun link
```

## Global bin directory

Globally-linked binaries are stored in:

* **macOS/Linux**: `~/.bun/install/global/bin`
* **Windows**: `%USERPROFILE%\.bun\install\global\bin`

Unlinking removes binaries from this directory.

## Use cases

### Clean up after development

```bash theme={null}
# Done developing a local package
cd ~/projects/my-lib
bun unlink

# Unlink from projects using it
cd ~/projects/my-app
bun remove my-lib
bun add my-lib  # Install from registry instead
```

### Switch to published version

```bash theme={null}
# Unlink local development version
cd ~/projects/my-package
bun unlink

# Install published version in app
cd ~/projects/my-app  
bun remove my-package
bun add my-package
```

### Resolve link conflicts

If a package link is broken:

```bash theme={null}
cd ~/projects/package
bun unlink
bun link  # Re-register
```

## Common issues

### Package not linked

If running `bun unlink` shows "package is not globally linked":

```bash theme={null}
$ bun unlink
success: package "my-package" is not globally linked, so there's nothing to do.
```

The package wasn't linked globally. This is not an error.

### Projects still reference the package

Unlinking doesn't automatically remove the package from projects using it. You must manually remove it:

```bash theme={null}
cd ~/projects/app
bun remove my-package
```

## See also

* [bun link](/cli/link) - Link packages
* [bun remove](/cli/remove) - Remove packages from a project
