From a7f753eb90b80d4a23b43f8d09b849a4ff9b3ebd Mon Sep 17 00:00:00 2001 From: Max Black Date: Wed, 19 Nov 2025 15:04:02 -0800 Subject: [PATCH] docs: add workspace dependencies example to workspaces --- docs/lib/content/using-npm/workspaces.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/docs/lib/content/using-npm/workspaces.md b/docs/lib/content/using-npm/workspaces.md index e7f87ed2609cc..91d0f99745a25 100644 --- a/docs/lib/content/using-npm/workspaces.md +++ b/docs/lib/content/using-npm/workspaces.md @@ -86,6 +86,26 @@ If you want to add a dependency named `abbrev` from the registry as a dependency npm install abbrev -w a ``` +**Adding a workspace as a dependency of another workspace:** + +If you want to add workspace **b** as a dependency of workspace **a**, you can use the workspace protocol in the dependency specifier: + +``` +npm install b@workspace:* -w a +``` + +This will add an entry to workspace **a**'s `package.json` like: + +```json +{ + "dependencies": { + "b": "workspace:*" + } +} +``` + +The `workspace:` protocol tells npm to link to the local workspace rather than fetching from the registry. The `*` version means it will use whatever version is defined in workspace **b**'s `package.json`. + Note: other installing commands such as `uninstall`, `ci`, etc will also respect the provided `workspace` configuration. ### Using workspaces