# resolve-from-npm

> Resolve the path of a module from the directory where npm is installed

Latest version **4.2.0** (published 2019-06-11) · ISC license · 0 weekly downloads

## Install

```sh
npm install resolve-from-npm
pnpm add resolve-from-npm
yarn add resolve-from-npm
bun add resolve-from-npm
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.2.0 |
| Published | 2019-06-11 |
| First published | 2015-12-02 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 4.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Watanabe Shinnosuke |
| Maintainers | shinnn |
| Keywords | npm, resolve, from, base, path, filepath, module, dir, find, promise, promises, then |

## Links

- npm: https://www.npmjs.com/package/resolve-from-npm
- Repository: https://github.com/shinnn/resolve-from-npm
- Homepage: https://github.com/shinnn/resolve-from-npm#readme
- Issues: https://github.com/shinnn/resolve-from-npm/issues
- npm.io page: https://npm.io/package/resolve-from-npm

## Dependencies (2)

- [npm-cli-dir](https://npm.io/package/npm-cli-dir.md) ^4.0.0
- [inspect-with-kind](https://npm.io/package/inspect-with-kind.md) ^1.0.5

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

- 4.2.0 (latest) — 2019-06-11
- 4.1.0 — 2019-06-11
- 4.0.0 — 2019-06-06
- 3.1.0 — 2018-07-09
- 3.0.0 — 2018-06-11
- 3.0.0-1 — 2018-06-04
- 3.0.0-0 — 2018-05-28
- 2.0.4 — 2018-01-29
- 2.0.3 — 2017-11-27
- 2.0.3-0 — 2017-11-22
- 2.0.2 — 2017-05-08
- 2.0.1 — 2017-05-02
- 2.0.0 — 2016-06-28
- 1.0.0 — 2015-12-03
- 0.0.0 — 2015-12-02

## README

# resolve-from-npm

[![npm version](https://img.shields.io/npm/v/resolve-from-npm.svg)](https://www.npmjs.com/package/resolve-from-npm)
[![Build Status](https://travis-ci.com/shinnn/resolve-from-npm.svg?branch=master)](https://travis-ci.com/shinnn/resolve-from-npm)
[![codecov](https://codecov.io/gh/shinnn/resolve-from-npm/branch/master/graph/badge.svg)](https://codecov.io/gh/shinnn/resolve-from-npm)

Resolve the path of a module from the directory where [npm CLI](https://github.com/npm/cli) is installed

```javascript
const resolveFromNpm = require('resolve-from-npm');

require.resolve('node-fetch-npm');
//=> '/path/to/the/current/directory/node_modules/node-fetch-npm/src/index.js'

(async () => {
  await resolveFromNpm('node-fetch-npm');
  //=> '/usr/local/lib/node_modules/npm/node_modules/node-fetch-npm/src/index.js'
})();
```

## Installation

[Use](https://docs.npmjs.com/cli/install) [npm](https://docs.npmjs.com/about-npm/).

```
npm install resolve-from-npm
```

## API

```javascript
const resolveFromNpm = require('resolve-from-npm');
```

### resolveFromNpm(*moduleId*)

*moduleId*: `string` (a module ID)  
Return: `Promise<string>`

It resolves the path of a module from the path where [npm-cli-dir](https://github.com/shinnn/npm-cli-dir) resolves.

```javascript
(async () => {
  await resolveFromNpm('./lib/install'); //=> '/usr/local/lib/node_modules/npm/lib/install.js'
})();

(async () => {
  try {
    // npm CLI doesn't contain a file './hi'
    await resolveFromNpm('./hi');
  } catch (err) {
    err.code; //=> 'MODULE_NOT_FOUND'
    err.message; //=> "Cannot find module './hi' from npm directory '/usr/local/lib/node_modules/npm'."
    err.npmDir; //=> '/usr/local/lib/node_modules/npm'
  }
})();
```

## License

[ISC License](./LICENSE) © 2017 - 2019 Watanabe Shinnosuke

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