# global-directory

> Get the directory of globally installed packages and binaries

Latest version **5.0.0** (published 2026-02-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install global-directory
pnpm add global-directory
yarn add global-directory
bun add global-directory
```

## Health

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

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 5.0.0 |
| Published | 2026-02-02 |
| First published | 2023-11-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=20 |
| Dependencies | 1 |
| Unpacked size | 11.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Sindre Sorhus |
| Maintainers | sindresorhus |
| Keywords | global, prefix, path, paths, npm, yarn, pnpm, node, modules, node-modules, package, packages, binary, binaries, bin, directory, directories, npmrc, rc, config, root, resolve |

## Links

- npm: https://www.npmjs.com/package/global-directory
- Repository: https://github.com/sindresorhus/global-directory
- Homepage: https://github.com/sindresorhus/global-directory#readme
- Issues: https://github.com/sindresorhus/global-directory/issues
- Funding: https://github.com/sponsors/sindresorhus
- npm.io page: https://npm.io/package/global-directory

## Dependencies (1)

- [ini](https://npm.io/package/ini.md) 6.0.0

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

- 5.0.0 (latest) — 2026-02-02
- 4.0.1 — 2023-11-06
- 4.0.0 — 2023-11-06

## README

# global-directory

> Get the directory of globally installed packages and binaries

Uses the same resolution logic as `npm`, `yarn`, and `pnpm`.

## Install

```sh
npm install global-directory
```

## Usage

```js
import globalDirectory from 'global-directory';

console.log(globalDirectory.npm.prefix);
//=> '/usr/local'

console.log(globalDirectory.npm.packages);
//=> '/usr/local/lib/node_modules'

console.log(globalDirectory.npm.binaries);
//=> '/usr/local/bin'

console.log(globalDirectory.yarn.packages);
//=> '/Users/sindresorhus/.config/yarn/global/node_modules'

console.log(globalDirectory.pnpm.prefix);
//=> '/Users/sindresorhus/Library/pnpm'

console.log(globalDirectory.pnpm.packages);
//=> '/Users/sindresorhus/Library/pnpm/global/5/node_modules'
```

## API

### globalDirectory

#### npm
#### yarn
#### pnpm

##### packages

The directory with globally installed packages.

Equivalent to `npm root --global`.

##### binaries

The directory with globally installed binaries.

Equivalent to `npm bin --global`.

##### prefix

The directory with directories for packages and binaries. You probably want either of the above.

Equivalent to `npm prefix --global`.

## Related

- [import-global](https://github.com/sindresorhus/import-global) - Import a globally installed module
- [resolve-global](https://github.com/sindresorhus/resolve-global) - Resolve the path of a globally installed module
- [is-installed-globally](https://github.com/sindresorhus/is-installed-globally) - Check if your package was installed globally

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