# root-link-target

> Gets the shortest directory to which a file can be linked

Latest version **4.0.0** (published 2026-03-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install root-link-target
pnpm add root-link-target
yarn add root-link-target
bun add root-link-target
```

## Health

**Score 65/100 (B)** — status: stable.

Positive: has types; esm support; no vulnerabilities; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 4.0.0 |
| Published | 2026-03-11 |
| First published | 2018-02-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=22.13 |
| Dependencies | 3 |
| Unpacked size | 3.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 104 |
| Author | Zoltan Kochan <z@kochan.io> (https://www.kochan.io/) |
| Maintainers | zkochan |
| Keywords | link, hardlink, fs |

## Links

- npm: https://www.npmjs.com/package/root-link-target
- Repository: https://github.com/zkochan/packages/tree/main/root-link-target
- Homepage: https://github.com/zkochan/packages/tree/main/root-link-target#readme
- npm.io page: https://npm.io/package/root-link-target

## Dependencies (3)

- [can-link](https://npm.io/package/can-link.md) ^3.0.0
- [next-path](https://npm.io/package/next-path.md) ^1.0.0
- [path-temp](https://npm.io/package/path-temp.md) ^3.0.0

## Alternatives

- [unionfs](https://npm.io/package/unionfs.md) — 2.2M weekly downloads
- [path-starts-with](https://npm.io/package/path-starts-with.md) — 35.9K weekly downloads
- [redzip](https://npm.io/package/redzip.md) — 1.2K weekly downloads
- [vscode-anymatch](https://npm.io/package/vscode-anymatch.md) — 848 weekly downloads
- [@ledgerhq/coin-filecoin](https://npm.io/package/@ledgerhq/coin-filecoin.md) — 793 weekly downloads

## Recent versions

- 4.0.0 (latest) — 2026-03-11
- 3.1.0 (next) — 2021-02-11
- 3.0.0 — 2021-01-09
- 2.0.0 — 2019-05-04
- 1.0.1 — 2018-02-17
- 1.0.0 — 2018-02-17

## README

# root-link-target

> Gets the shortest directory to which a file can be linked

<!--@shields('npm')-->
[![npm version](https://img.shields.io/npm/v/root-link-target.svg)](https://www.npmjs.com/package/root-link-target)
<!--/@-->

## Installation

```sh
<npm|yarn|pnpm> add root-link-target
```

## Usage

```js
const rootLinkTarget = require('root-link-target')

rootLinkTarget.sync('C:\\sub\\dir\\foo.txt')
//> C:\\
```

## API

### `rootLinkTarget.sync(filename): string`

Returns the shortest directory to which `filename` can be linked

### `rootLinkTarget(filename): Promise<string>`

## License

[MIT](./LICENSE) © [Zoltan Kochan](https://www.kochan.io/)

---
_Source: https://npm.io/package/root-link-target · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
