---
source: https://iinventedlight.com/library/notes/pnpm-workspaces.md
title: "pnpm workspaces list projects in pnpm-workspace.yaml and link them with the workspace: protocol"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "MIT (pnpm docs); MIT (pnpm/pnpm.io (GitHub)); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: pnpm docs, Workspace; pnpm/pnpm.io (GitHub), Workspace (source page). MIT (https://raw.githubusercontent.com/pnpm/pnpm.io/main/LICENSE). Copyright pnpm contributors."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-18
status: published
approved_by: "Cole Withington, 2026-11-20 13:14 PT: \"Publish the full batch and rewrite the 6 live notes\""
checked_on: 2026-11-18
as_of: 2026-11-18
confidence: medium
untested: "Not reproduced (2026-11-18). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-web: pnpm workspaces"
tags: [pnpm, workspaces, monorepo, workspace-protocol, pnpm-workspace.yaml]
client: Librarian
sources:
  - id: S1
    title: "Workspace"
    publisher: pnpm docs
    url: https://pnpm.io/workspaces
    accessed: 2026-11-18
    license: "MIT"
  - id: S2
    title: "Workspace (source page)"
    publisher: pnpm/pnpm.io (GitHub)
    url: https://github.com/pnpm/pnpm.io/blob/main/docs/workspaces.md
    accessed: 2026-11-18
    license: "MIT"
---
# pnpm workspaces list projects in pnpm-workspace.yaml and link them with the workspace: protocol
**Answer:** Put a `pnpm-workspace.yaml` file in the repository root; its `packages` field lists the directories of the workspace's projects. Depend on sibling packages with `"foo": "workspace:*"` so pnpm refuses to resolve to anything other than a local workspace package.

## Files

```yaml
# pnpm-workspace.yaml
packages:
  - packages/*
```

```json
{ "dependencies": { "foo": "workspace:*", "bar": "workspace:~", "qar": "workspace:^", "zoo": "workspace:^1.5.0" } }
```

## Why the workspace: protocol

With `linkWorkspacePackages` set to `true`, pnpm links workspace packages only when they match the declared range; otherwise, for instance when `foo@2.0.0` is not in the workspace, it installs `foo@2.0.0` from the registry. This behavior introduces some uncertainty, which the `workspace:` protocol avoids: with `"foo": "workspace:2.0.0"`, installation will fail. A relative spec such as `"foo": "workspace:../foo"` also works.

## What publishing does

When a package is packed by `pnpm pack` or a publish command such as `pnpm publish`, each `workspace:` dependency is replaced dynamically. `workspace:*`, `workspace:~` and `workspace:^` become the target package's version (with `~` or `^` kept), and other ranges become the associated semver range. If all packages are at version 1.5.0, the example above is transformed into `1.5.0`, `~1.5.0`, `^1.5.0` and `^1.5.0`. A bare `workspace:` without a range is treated as `workspace:*`.

## Migrating from npm, Yarn or Bun

Since v12.7.0, if the root `package.json` has a `workspaces` field and there is no `pnpm-workspace.yaml`, `pnpm install` creates one with the same patterns. Only `pnpm-workspace.yaml` is read afterwards.

## See also

- [pnpm-filtering](https://iinventedlight.com/library/notes/pnpm-filtering/)
- [node-package-exports](https://iinventedlight.com/library/notes/node-package-exports/)
- [node-esm](https://iinventedlight.com/library/notes/node-esm/)

## Claims

- id: C1
  claim: A workspace needs pnpm-workspace.yaml in its root.
  source: S2
  evidence: "A workspace must have a [`pnpm-workspace.yaml`] file in its root."

- id: C2
  claim: The workspace: protocol resolves only to local workspace packages.
  source: S2
  evidence: "pnpm will refuse to resolve to anything other than a local workspace package"

- id: C3
  claim: A bare workspace: is treated as workspace:*.
  source: S2
  evidence: "A bare `workspace:` without a version range is treated as `workspace:*`."

- id: C4
  claim: The packages field lists the workspace project directories.
  source: S1
  evidence: "field lists the directories of the workspace's projects"

## Sources

- [S1] Workspace. pnpm docs. https://pnpm.io/workspaces . License: MIT. Accessed 2026-11-18.

- [S2] Workspace (source page). pnpm/pnpm.io (GitHub). https://github.com/pnpm/pnpm.io/blob/main/docs/workspaces.md . License: MIT. Accessed 2026-11-18.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: pnpm docs, Workspace; pnpm/pnpm.io (GitHub), Workspace (source page). MIT (https://raw.githubusercontent.com/pnpm/pnpm.io/main/LICENSE). Copyright pnpm contributors. Text was condensed and changed from the originals.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
