npm install never links the local package
npm install does not link the local package. pnpm install at the root with workspace:* does.
npm install in a pnpm workspace does not link the local package. To show a teammate the install that does, open a browser room on figmeet and walk the root pnpm install.
People searching pnpm workspace first install that links have usually already run npm install in a package folder. A package-lock is not the link. The docs want pnpm-workspace.yaml at the root, the dependency workspace:*, then pnpm install at the repo root.
The install that actually links
-
1
Put pnpm-workspace.yaml at the root
A workspace must have this file.
packageslists project directories, for examplepackages/*. Since v12.7.0, if package.json has aworkspacesfield and no yaml yet,pnpm installcreates the yaml with the same patterns and links on that same install. An existing yaml is never rewritten.--ignore-workspacecreates nothing. npm install does not do this. -
2
Depend with workspace:*
In the consumer package.json, set
"foo": "workspace:*". The protocol refuses anything that is not a local workspace package.workspace:2.0.0fails the install when foo@2.0.0 is absent. It does not switch to the registry. A bareworkspace:is treated asworkspace:*. -
3
Run pnpm install at the repo root
Inside a workspace,
pnpm installinstalls dependencies in every project. SetrecursiveInstallto false to disable that. Do not pass--lockfile-only: it updates the lockfile and package.json and writes nothing to node_modules. Do not pass--ignore-workspace: the current project is installed standalone and a parent yaml is ignored.
A plain version still does not link
The protocol forces local
With linkWorkspacePackages off, only a workspace: spec links a package from the workspace. A matching version is not, by itself, a local link.
Turning the option on still checks the range
Set linkWorkspacePackages to true and foo@1.0.0 links into a project that depends on ^1.0.0. If the spec asks for 2.0.0 and that version is not in the workspace, pnpm still downloads it from the registry.
Publish rewrites the protocol
pnpm pack and pnpm publish replace workspace:. In the docs example every package is 1.5.0: workspace:* becomes 1.5.0, workspace:~ becomes ~1.5.0, and workspace:^ becomes ^1.5.0.
# pnpm-workspace.yaml
packages:
- packages/*
# packages/bar/package.json
"foo": "workspace:*"
# repo root — this install links
pnpm install
| Command | What it reads | Local package |
|---|---|---|
| npm install | Does not read pnpm-workspace.yaml | No workspace: link |
| pnpm install | yaml + workspace:* | Links the in-repo package |
| Plain ^1.0.0 | linkWorkspacePackages defaults to false | Downloaded from the registry |
Once the link is in place, create a room on figmeet and show the yaml and the consumer’s workspace:* . Join steps are in create and join. A few minutes of that does not need another meeting client; see when not to use heavy meeting apps.
Easy to think it already linked
If workspace:2.0.0 is missing locally, does pnpm use the registry?
No. The docs say the protocol resolves only to a local workspace package. If foo@2.0.0 is not in the workspace, pnpm install fails. It does not fetch the same name from the registry.
Why download when the range already covers the local package?
linkWorkspacePackages defaults to false, so a plain range is installed from the registry. Set it to true and a link still requires the version to satisfy the range. To refuse the registry, use workspace:.
pnpm install in CI did not link. What should I check first?
If a lockfile is present but out of date with the manifest, pnpm install fails in CI. Update it with pnpm install --no-frozen-lockfile. --lockfile-only writes nothing to node_modules, so there is no link.
If package.json only has a workspaces field, will npm install link it?
That is not this link. With no yaml, pnpm install (since v12.7.0) creates pnpm-workspace.yaml from the workspaces field and links on that same install. When a yaml already exists, pnpm reads only the yaml. Differing patterns produce a warning. npm’s field is still not what gets linked.