---
title: "@vltpkg/tar: link-tree — vlt docs"
description: "Documentation for the vlt client and the vlt registry."
url: "https://docs.vlt.io/client/api-reference/tar/link-tree"
image: "https://docs.vlt.io/og/client/api-reference/tar/link-tree"
lang: "en"
---

# link-tree

## Type Aliases

### LinkFromStoreOptions

```ts
type LinkFromStoreOptions = object;
```

Defined in: tar/src/link-tree.ts:47

#### Type declaration

| Name     | Type      | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| -------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `clone`? | `boolean` | clone the entry directory copy-on-write (`clonefile(2)`: macOS on APFS) instead of placing files one by one. A failed clone is a store miss, so the caller unpacks: on APFS, hardlinking file by file is slower than that. Where a clone cannot work at all (no clones on this filesystem, another volume), every later call is a miss without trying. A clone shares no file with the store, so it needs no copy on top, for `copy` or for install scripts. |
| `copy`?  | `boolean` | copy every file instead of hardlinking                                                                                                                                                                                                                                                                                                                                                                                                                       |

---

### StoreLinker

```ts
type StoreLinker = "auto" | "hardlink" | "clone" | "copy" | "unpack";
```

Defined in: tar/src/link-tree.ts:36

How reify places packages: `auto` and `hardlink` link from the global store, `clone` clones from it (macOS), `copy` copies from it, `unpack` skips it.

---

### StoreLinkResult

```ts
type StoreLinkResult = 
  | {
  how: "link" | "clone" | "copy";
  index: StoreIndex;
 }
  | false;
```

Defined in: tar/src/link-tree.ts:44

How a store entry was placed (`clone`: the whole directory cloned copy-on-write; `copy`: every file copied, for `copy` or a downgrade) and its index, or false on a miss.

## Functions

### linkFromStore()

```ts
function linkFromStore(
   storeEntry, 
   target, 
   __namedParameters): StoreLinkResult
```

Defined in: tar/src/link-tree.ts:242

Materialize a global store entry at `target` from its sidecar index: hardlink each file into a sibling temp dir (package.json last), or with `clone` clone the whole entry there, then rename it into place. Files that cannot be linked are copied; if package.json is copied after another file was linked, the whole package is copied, so a private package.json means nothing is shared. Returns how, with the index, or false, leaving `target` untouched, on a store miss (no valid index, entry not a directory, symlinked target parent, a failed clone), a name clash on a case-insensitive target, or a damaged entry, which is removed.

#### Parameters

| Parameter           | Type                                                                                                     |
| ------------------- | -------------------------------------------------------------------------------------------------------- |
| `storeEntry`        | `string`                                                                                                 |
| `target`            | `string`                                                                                                 |
| `__namedParameters` | [`LinkFromStoreOptions`](https://docs.vlt.io/client/api-reference/tar/link-tree.md#linkfromstoreoptions) |

#### Returns

[`StoreLinkResult`](https://docs.vlt.io/client/api-reference/tar/link-tree.md#storelinkresult)
