Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions docs/lib/content/using-npm/workspaces.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,24 +88,25 @@ 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:
The same approach works when adding one workspace as a dependency of another.
If you want to add workspace **b** as a dependency of workspace **a**, run:

```
npm install b@workspace:* -w a
npm install b -w a
```

This will add an entry to workspace **a**'s `package.json` like:
npm will detect that **b** is a workspace and automatically symlink it rather
than fetching it from the registry. The resulting entry in workspace **a**'s
`package.json` will use a standard version range:

```json
{
"dependencies": {
"b": "workspace:*"
"b": "^1.0.0"
}
}
```

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
Expand Down
Loading