# hash-for-dep

> generates a hash that represents a module and its depenencies uniqueness

Latest version **1.5.2** (published 2026-02-23) · ISC license · 0 weekly downloads

## Install

```sh
npm install hash-for-dep
pnpm add hash-for-dep
yarn add hash-for-dep
bun add hash-for-dep
```

## Health

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

Positive: no vulnerabilities; has provenance.

Warnings: low downloads; no types; no esm support.

## Facts

| | |
|---|---|
| Version | 1.5.2 |
| Published | 2026-02-23 |
| First published | 2015-04-13 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 33.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 7 |
| Author | Stefan Penner |
| Maintainers | kellyselden, rwjblue, katiegengler, stefanpenner |

## Links

- npm: https://www.npmjs.com/package/hash-for-dep
- Repository: https://github.com/ember-cli/hash-for-dep
- Homepage: https://github.com/ember-cli/hash-for-dep#readme
- Issues: https://github.com/ember-cli/hash-for-dep/issues
- npm.io page: https://npm.io/package/hash-for-dep

## Dependencies (4)

- [resolve](https://npm.io/package/resolve.md) ^1.10.0
- [heimdalljs](https://npm.io/package/heimdalljs.md) ^0.2.3
- [heimdalljs-logger](https://npm.io/package/heimdalljs-logger.md) ^0.1.7
- [resolve-package-path](https://npm.io/package/resolve-package-path.md) ^1.0.11

## Recent versions

- 1.5.2 (latest) — 2026-02-23
- 1.5.1 — 2019-03-21
- 1.5.0 — 2019-03-02
- 1.4.7 — 2019-02-20
- 1.4.6 — 2019-02-18
- 1.4.5 — 2019-02-12
- 1.4.4 — 2019-02-12
- 1.4.3 — 2019-02-11
- 1.4.0 — 2019-02-11
- 1.3.1 — 2019-02-07
- 1.3.0 — 2019-02-07
- 1.2.3 — 2017-11-08
- 1.2.2 — 2017-10-23
- 1.2.1 — 2017-10-12
- 1.2.0 — 2017-07-31
- … 12 more at https://npm.io/package/hash-for-dep/versions

## README

# hash-for-dep [![Build Status](https://travis-ci.org/stefanpenner/hash-for-dep.svg?branch=stuff)](https://travis-ci.org/stefanpenner/hash-for-dep) [![Build status](https://ci.appveyor.com/api/projects/status/wf2u3j6lc52hdd21?svg=true)](https://ci.appveyor.com/project/embercli/hash-for-dep)

Generate a hash representing the stats of this module files and all its descendents files.


```js
var hashForDep = require('hash-for-dep');

hashForDep('rsvp'); // if RSVP is a dependency of the current project, you will get a checksum for it
hashForDep('rsvp', 'path/to/other/project'); //  you will get a checksum for RSVP resolved relative to the provided root
```

## What does Hash For Dep consider a dependency?

HashForDep respects the [node resolution algorithim](https://nodejs.org/api/modules.html#modules_all_together).

For example given:

```
foo/package.json
foo/index.js
foo/node_modules/a/
foo/node_modules/a/package.json
foo/node_modules/a/index.js
foo/node_modules/a/node_modules/b
foo/node_modules/a/node_modules/b/package.json
foo/node_modules/a/node_modules/b/index.js
foo/node_modules/a/node_modules/f
foo/node_modules/a/node_modules/f/index.js
foo/node_modules/a/node_modules/f/package.json
foo/node_modules/c
foo/node_modules/c/index.js
foo/node_modules/c/package.json
foo/node_modules/d
foo/node_modules/d/index.js
foo/node_modules/d/package.js
```

where `foo/package.json` depends on `a` and `c` but not `d`
and `foo/node_modules/a/package.json` depends on `b` not `f`

HashForDep will consider: `a` `c` `b` as dependencies, and simply ignore `d` and `f`.
When HashForDep considers a dependency, it will stat each of its files and those of its dependencies.


## Cache

NOTE: By default, these hashes are cached for the life of the process. As this
is the same strategy node uses for `require(x)` we can safely follow suit.

That being said, some scenarios may exist where this is not wanted. So just
like `require._cache` exists, we provide the following options:

#### To evict the cache manually (maybe for testing)

```js
require('hash-for-dep')._resetCache();
```

#### To opt out of the cache on a per invocation basis

```js
var hashForDep = require('hash-for-dep');

hashForDep(name, path, null, false /* this mysterious argument should be set to false */);
```

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