# find-module

> find a module from a require path asyncronously using custom module folders

Latest version **0.2.1** (published 2013-08-19) · 0 weekly downloads

## Install

```sh
npm install find-module
pnpm add find-module
yarn add find-module
bun add find-module
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.1 |
| Published | 2013-08-19 |
| First published | 2012-12-16 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Ge.tt |
| Maintainers | mafintosh |
| Keywords | modules, require, resolve |

## Links

- npm: https://www.npmjs.com/package/find-module
- Repository: https://github.com/gett/find-module
- Issues: https://github.com/gett/find-module/issues
- npm.io page: https://npm.io/package/find-module

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

- 0.2.1 (latest) — 2013-08-19
- 0.2.0 — 2013-02-09
- 0.1.1 — 2012-12-16
- 0.1.0 — 2012-12-16

## README

# find-module

Find a module specified by a require path using Node's module resolution.

	npm install find-module

## Usage

``` js
var findModule = require('find-module');

findModule('./some-path', {
	dirname: 'some-parent-dir' // the directory from which ./some-path should be resolved
}, function(err, filename) {
	console.log('some-path resolved to '+filename+' from some-parent-dir');
});

// or dont provide a callback to use the sync version

var filename = findModule('./some-path', {
	dirname: 'some-parent-dir' // the directory from which ./some-path should be resolved
});

console.log('some-path resolved to '+filename+' from some-parent-dir');
```

If you pass a module path (`'my-module'`) find-module by default will look for a `node_modules` folder
to find `my-module`. If you want to use a different module folder you can set the `modules` option

``` js
findModule('my-module', {
	modules: 'custom_modules',
	dirname: 'some-parent-dir'
}, ...);
```

When you resolve a path find-module by default will look for `path+'.js'` and `path+'.json'` if the
path does not exist. If you want to look for other kind of extensions set the `extensions` option

``` js
findModule('my-module', {
	dirname: 'some-parent-dir',
	extensions: ['txt']
}, ...);
```

Combine the `modules` and `extensions` settings to roll out your own module finder. A template module
finder could look like this

``` js
findModule('my-template', {
	dirname: 'some-parent-dir',
	modules: 'templates',
	extensions: ['html']
}, ...);
```

## License

MIT

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