# walk-back

> Walk up the directory tree until the specified path is found.

Latest version **5.1.2** (published 2026-03-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install walk-back
pnpm add walk-back
yarn add walk-back
bun add walk-back
```

## Health

**Score 50/100 (C)** — status: stable.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

## Facts

| | |
|---|---|
| Version | 5.1.2 |
| Published | 2026-03-07 |
| First published | 2015-09-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM |
| Node | >=12.17 |
| Dependencies | 0 |
| Unpacked size | 8.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 17 |
| Author | Lloyd Brookes |
| Maintainers | 75lb |
| Keywords | walk, up, back, filesystem, fs, find, file, search, system, config |

## Links

- npm: https://www.npmjs.com/package/walk-back
- Repository: https://github.com/75lb/walk-back
- Homepage: https://github.com/75lb/walk-back#readme
- Issues: https://github.com/75lb/walk-back/issues
- npm.io page: https://npm.io/package/walk-back

## 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

- 5.1.2 (latest) — 2026-03-07
- 5.1.1 — 2024-08-23
- 5.1.0 — 2021-08-18
- 5.0.0 — 2021-02-26
- 4.0.0 — 2019-11-06
- 3.0.1 — 2018-12-24
- 3.0.0 — 2017-03-19
- 2.0.1 — 2016-05-25
- 2.0.0 — 2016-05-24
- 1.1.1 — 2016-02-26
- 1.1.0 — 2016-01-22
- 1.0.1 — 2015-11-11
- 1.0.0 — 2015-11-11
- 0.1.1 — 2015-09-20

## README

[![view on npm](https://badgen.net/npm/v/walk-back)](https://www.npmjs.org/package/walk-back)
[![npm module downloads](https://badgen.net/npm/dt/walk-back)](https://www.npmjs.org/package/walk-back)
[![Gihub repo dependents](https://badgen.net/github/dependents-repo/75lb/walk-back)](https://github.com/75lb/walk-back/network/dependents?dependent_type=REPOSITORY)
[![Gihub package dependents](https://badgen.net/github/dependents-pkg/75lb/walk-back)](https://github.com/75lb/walk-back/network/dependents?dependent_type=PACKAGE)
[![Node.js CI](https://github.com/75lb/walk-back/actions/workflows/node.js.yml/badge.svg)](https://github.com/75lb/walk-back/actions/workflows/node.js.yml)

<a name="module_walk-back"></a>

## walk-back
Walk up the directory tree until the specified path is found. For example, starting from the current directory, you might want to walk up the directory tree until a specified config file is found.

**Example**  
```js
import walkBack from 'walk-back'
```
<a name="exp_module_walk-back--walkBack"></a>

### walkBack(startAt, lookingFor) ⇒ <code>string</code> ⏏
Returns an absolute file path (if found) else `null`.

**Kind**: Exported function  

| Param | Type | Description |
| --- | --- | --- |
| startAt | <code>string</code> | the directory to start in |
| lookingFor | <code>string</code> | the path we're looking for |

**Example**  
```js
> walkBack('/Users/lloyd/Documents/75lb/walk-back', 'package.json')
'/Users/lloyd/Documents/75lb/walk-back/package.json'

> walkBack('/Users/lloyd/Documents/75lb/walk-back', '75lb')
'/Users/lloyd/Documents/75lb'

> walkBack('/Users/lloyd/Documents/75lb/walk-back', '.bash_profile')
'/Users/lloyd/.bash_profile'

> walkBack('.', '.bash_profile')
'/Users/lloyd/.bash_profile'

> walkBack('/Users/lloyd/Documents/75lb/walk-back', 'non-existent.file')
null
```

* * *

&copy; 2015-26 Lloyd Brookes \<opensource@75lb.com\>.

Tested by [test-runner](https://github.com/test-runner-js/test-runner). Documented by [jsdoc-to-markdown](https://github.com/jsdoc2md/jsdoc-to-markdown).

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