You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/lib/content/using-npm/workspaces.md
+20Lines changed: 20 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -86,6 +86,26 @@ If you want to add a dependency named `abbrev` from the registry as a dependency
86
86
npm install abbrev -w a
87
87
```
88
88
89
+
**Adding a workspace as a dependency of another workspace:**
90
+
91
+
If you want to add workspace **b** as a dependency of workspace **a**, you can use the workspace protocol in the dependency specifier:
92
+
93
+
```
94
+
npm install b@workspace:* -w a
95
+
```
96
+
97
+
This will add an entry to workspace **a**'s `package.json` like:
98
+
99
+
```json
100
+
{
101
+
"dependencies": {
102
+
"b": "workspace:*"
103
+
}
104
+
}
105
+
```
106
+
107
+
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`.
108
+
89
109
Note: other installing commands such as `uninstall`, `ci`, etc will also respect the provided `workspace` configuration.
0 commit comments