# npm-root

> Get the node modules directory, a.k.a. npm root. Global or local.

Latest version **1.1.0** (published 2015-08-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install npm-root
pnpm add npm-root
yarn add npm-root
bun add npm-root
```

## 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 | 1.1.0 |
| Published | 2015-08-06 |
| First published | 2015-07-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 8 |
| Author | Joakim Carlstein |
| Maintainers | joakimbeng |
| Keywords | npm, root, npm, dir, node, modules, modules, location |

## Links

- npm: https://www.npmjs.com/package/npm-root
- Repository: https://github.com/joakimbeng/npm-root
- Homepage: https://github.com/joakimbeng/npm-root#readme
- Issues: https://github.com/joakimbeng/npm-root/issues
- npm.io page: https://npm.io/package/npm-root

## Alternatives

- [@expo/fingerprint](https://npm.io/package/@expo/fingerprint.md) — 6.2M weekly downloads
- [@azure/monitor-opentelemetry-exporter](https://npm.io/package/@azure/monitor-opentelemetry-exporter.md) — 850.0K weekly downloads
- [@azure/monitor-opentelemetry](https://npm.io/package/@azure/monitor-opentelemetry.md) — 624.0K weekly downloads
- [@posthog/ai](https://npm.io/package/@posthog/ai.md) — 423.3K weekly downloads
- [fakefilter](https://npm.io/package/fakefilter.md) — 63.9K weekly downloads

## Recent versions

- 1.1.0 (latest) — 2015-08-06
- 1.0.0 — 2015-07-21

## README

# npm-root

[![NPM version][npm-image]][npm-url]

> Get the node modules directory, a.k.a. npm root. Global or local.

## Installation

Install `npm-root` using [npm](https://www.npmjs.com/):

```bash
npm install --save npm-root
```

## Usage

### Module usage

```javascript
var npmRoot = require('npm-root');

// Get the local node_modules path:
npmRoot(function (err, localPath) {
  // ...
});

// Get the local node_modules path for another directory:
npmRoot({cwd: '/path/to/other/folder'}, function (err, localPath) {
  // ...
});

// Get the global node_modules path:
npmRoot({global: true}, function (err, globalPath) {
  // ...
});
```

## API

### `npmRoot(opts, cb)`

| Name | Type | Description |
|------|------|-------------|
| opts | `Object` | Options (optional) |
| cb | `Function` | Callback function |

#### opts.global

Set this to get the global node_modules path instead of the local.

#### opts.cwd

Change current working directory, affects only the local node_modules path.


## License

MIT

[npm-url]: https://npmjs.org/package/npm-root
[npm-image]: https://badge.fury.io/js/npm-root.svg

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