# resolve-dependency-path

> Convert a dependency path into a filepath

Latest version **5.0.0** (published 2026-05-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install resolve-dependency-path
pnpm add resolve-dependency-path
yarn add resolve-dependency-path
bun add resolve-dependency-path
```

## Health

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

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

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 5.0.0 |
| Published | 2026-05-19 |
| First published | 2014-11-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=20.19.0 \|\| >=22.12.0 |
| Dependencies | 0 |
| Unpacked size | 7.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Joel Kemp |
| Maintainers | pahen, mrjoelkemp, xhmikosr |
| Keywords | dependency, filepath, module |

## Links

- npm: https://www.npmjs.com/package/resolve-dependency-path
- Repository: https://github.com/dependents/node-resolve-dependency-path
- Issues: https://github.com/dependents/node-resolve-dependency-path/issues
- npm.io page: https://npm.io/package/resolve-dependency-path

## Alternatives

- [base64url](https://npm.io/package/base64url.md) — 6.1M weekly downloads
- [get-installed-path](https://npm.io/package/get-installed-path.md) — 502.9K weekly downloads
- [@uppy/url](https://npm.io/package/@uppy/url.md) — 185.8K weekly downloads
- [@d3fc/d3fc-shape](https://npm.io/package/@d3fc/d3fc-shape.md) — 16.2K weekly downloads
- [localizer](https://npm.io/package/localizer.md) — 226 weekly downloads

## Recent versions

- 5.0.0 (latest) — 2026-05-19
- 4.0.1 — 2025-02-01
- 4.0.0 — 2024-04-10
- 3.0.2 — 2023-05-07
- 3.0.1 — 2023-05-07
- 3.0.0 — 2023-05-06
- 2.0.0 — 2018-12-21
- 1.0.2 — 2015-02-28
- 1.0.1 — 2014-11-28

## README

# resolve-dependency-path

[![CI](https://img.shields.io/github/actions/workflow/status/dependents/node-resolve-dependency-path/ci.yml?branch=main&label=CI&logo=github)](https://github.com/dependents/node-resolve-dependency-path/actions/workflows/ci.yml?query=branch%3Amain)
[![npm version](https://img.shields.io/npm/v/resolve-dependency-path?logo=npm&logoColor=fff)](https://www.npmjs.com/package/resolve-dependency-path)
[![npm downloads](https://img.shields.io/npm/dm/resolve-dependency-path)](https://www.npmjs.com/package/resolve-dependency-path)

> Convert a dependency path into a filepath

```sh
npm install resolve-dependency-path
```

## Usage

### ESM

```js
import resolvePath from 'resolve-dependency-path';

const resolved = resolvePath({
  dependency: './foobar',
  filename: 'path/to/file/containing/dependency.js',
  directory: 'path/to/all/files'
});
```

### CommonJS

```js
const { default: resolvePath } = require('resolve-dependency-path');
```

### Options

| Option | Type | Required | Description |
|---|---|---|---|
| `dependency` | `string` | Yes | The dependency specifier (e.g. the argument to `require()`) |
| `filename` | `string` | Yes | Absolute or relative path of the file that contains the dependency |
| `directory` | `string` | Yes | Root directory used to resolve non-relative dependencies |

## Example

If you have a file like:

*myapp/foo.js*

```js
require('./bar');
```

Then if you want to open the file associated with the dependency, you need to resolve `./bar` onto the filesystem.

Since `./bar` is a relative path, it should be resolved relative to `foo.js`,
more specifically the directory containing `foo.js`, `myapp/`. This resolution would yield
`myapp/bar.js`.

This is why the `filename` attribute is required to use this library.

If you have a non-relative dependency path like:

*myapp/foo.js*

```js
define([
  'bar'
], function(bar) {

});
```

Then `bar` is relative to the root of all files, `myapp`. The resolution would yield
`myapp/bar.js`.

A more complex example with subdirectories:

*myapp/feature1/foo.js*

```js
define([
  'feature2/bar'
], function(bar) {

});
```

The dependency `feature2/bar` is relative to the root of all files, `myapp`, *not* the file `foo.js`.

This is why the `directory` attribute is required to use this library.

## License

[MIT](LICENSE)

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