# @npmcli/map-workspaces

> Retrieves a name:pathname Map for a given workspaces config

Latest version **6.0.0** (published 2026-05-22) · ISC license · 0 weekly downloads

## Install

```sh
npm install @npmcli/map-workspaces
pnpm add @npmcli/map-workspaces
yarn add @npmcli/map-workspaces
bun add @npmcli/map-workspaces
```

## Health

**Score 63/100 (C)** — status: active.

Positive: has types package; no vulnerabilities; has provenance; high maintenance score; high quality score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 6.0.0 |
| Published | 2026-05-22 |
| First published | 2020-03-12 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | separate (@types/npmcli__map-workspaces) |
| Module format | CommonJS |
| Node | ^22.22.2 \|\| ^24.15.0 \|\| >=26.0.0 |
| Dependencies | 4 |
| Unpacked size | 10.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 25 |
| Author | GitHub Inc. |
| Maintainers | saquibkhan, npm-cli-ops, reggi, owlstronaut |
| Keywords | npm, npmcli, libnpm, cli, workspaces, map-workspaces |

## Links

- npm: https://www.npmjs.com/package/@npmcli/map-workspaces
- Repository: https://github.com/npm/map-workspaces
- Homepage: https://github.com/npm/map-workspaces#readme
- Issues: https://github.com/npm/map-workspaces/issues
- npm.io page: https://npm.io/package/@npmcli/map-workspaces

## Dependencies (4)

- [glob](https://npm.io/package/glob.md) ^13.0.0
- [minimatch](https://npm.io/package/minimatch.md) ^10.0.3
- [@npmcli/package-json](https://npm.io/package/@npmcli/package-json.md) ^8.0.0
- [@npmcli/name-from-folder](https://npm.io/package/@npmcli/name-from-folder.md) ^5.0.0

## Alternatives

- [@salesforce/cli](https://npm.io/package/@salesforce/cli.md) — 389.7K weekly downloads
- [@mintlify/cli](https://npm.io/package/@mintlify/cli.md) — 208.9K weekly downloads
- [@grafana/e2e-selectors](https://npm.io/package/@grafana/e2e-selectors.md) — 128.7K weekly downloads
- [mintlify](https://npm.io/package/mintlify.md) — 112.0K weekly downloads
- [@intlayer/cli](https://npm.io/package/@intlayer/cli.md) — 22.8K weekly downloads

## Recent versions

- 6.0.0 (latest) — 2026-05-22
- 5.0.3 — 2025-11-21
- 5.0.2 — 2025-11-18
- 5.0.1 — 2025-10-23
- 5.0.0 — 2025-09-02
- 4.0.2 — 2024-11-20
- 4.0.1 — 2024-10-02
- 4.0.0 — 2024-09-26
- 3.0.6 — 2024-04-10
- 3.0.5 — 2024-04-10
- 3.0.4 — 2023-04-27
- 3.0.3 — 2023-03-21
- 3.0.2 — 2023-02-06
- 3.0.1 — 2022-12-15
- 3.0.0 — 2022-10-14
- … 12 more at https://npm.io/package/@npmcli/map-workspaces/versions

## README

# @npmcli/map-workspaces

[![NPM version](https://img.shields.io/npm/v/@npmcli/map-workspaces)](https://www.npmjs.com/package/@npmcli/map-workspaces)
[![Build Status](https://img.shields.io/github/actions/workflow/status/npm/map-workspaces/ci.yml?branch=main)](https://github.com/npm/map-workspaces)
[![License](https://img.shields.io/npm/l/@npmcli/map-workspaces)](https://github.com/npm/map-workspaces/blob/main/LICENSE.md)

Retrieves a name:pathname Map for a given workspaces config.

Long version: Reads the `workspaces` property from a valid **workspaces configuration** object and traverses the paths and globs defined there in order to find valid nested packages and return a **Map** of all found packages where keys are package names and values are folder locations.

## Install

`npm install @npmcli/map-workspaces`

## Usage:

```js
const mapWorkspaces = require('@npmcli/map-workspaces')
await mapWorkspaces({
  cwd,
  pkg: {
    workspaces: {
      packages: [
        "a",
        "b"
      ]
    }
  }
})
// ->
// Map {
//   'a': '<cwd>/a'
//   'b': '<cwd>/b'
// }
```

## Examples:

### Glob usage:

Given a folder structure such as:

```
├── package.json
└── apps
   ├── a
   │   └── package.json
   ├── b
   │   └── package.json
   └── c
       └── package.json
```

```js
const mapWorkspaces = require('@npmcli/map-workspaces')
await mapWorkspaces({
  cwd,
  pkg: {
    workspaces: [
      "apps/*"
    ]
  }
})
// ->
// Map {
//   'a': '<cwd>/apps/a'
//   'b': '<cwd>/apps/b'
//   'c': '<cwd>/apps/c'
// }
```

## API:

### `mapWorkspaces(opts) -> Promise<Map>`

- `opts`:
  - `pkg`: A valid `package.json` **Object**
  - `cwd`: A **String** defining the base directory to use when reading globs and paths.
  - `ignore`: An **Array** of paths to be ignored when using [globs](https://www.npmjs.com/package/glob) to look for nested package.
  - ...[Also support all other glob options](https://www.npmjs.com/package/glob#options)

#### Returns

A **Map** in which keys are **package names** and values are the **pathnames** for each found **workspace**.

## LICENSE

[ISC](./LICENSE)

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