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: 07-cloud/04-turborepo/01-workspaces/README.md
+23-34Lines changed: 23 additions & 34 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,18 +2,11 @@
2
2
3
3
In this example, we are going to learn how we can work with `npm` workspaces.
4
4
5
-
We will start from `00-boilerplate`.
5
+
We will start from `scratch` but we will copy some projects from `00-boilerplate`.
6
6
7
7
## Steps to build it
8
8
9
-
Let's start by creating the main `package.json` (we can use `npm init -y` to create it and then edit it):
10
-
11
-
```bash
12
-
npm init -y
13
-
14
-
```
15
-
16
-
Let's edit:
9
+
Let's start by creating the main `package.json`:
17
10
18
11
_./package.json_
19
12
@@ -31,7 +24,6 @@ _./.gitignore_
31
24
```
32
25
node_modules
33
26
dist
34
-
.turbo
35
27
36
28
```
37
29
@@ -81,7 +73,7 @@ npm install
81
73
82
74
```
83
75
84
-
Let's remove the `my-workspace` project and copy the `house-helpers` and `motto-helpers` projects from the `00-boilerplate` folder.
76
+
Let's remove the `my-workspace` project, the root `package-lock.json` and copy the `house-helpers` and `motto-helpers` projects from the `00-boilerplate` folder.
85
77
86
78
Let's run `npm install` again:
87
79
@@ -90,7 +82,7 @@ npm install
90
82
91
83
```
92
84
93
-
Notice that the `package-lock.json` has been updated with the `house-helpers` and `motto-helpers` projects dependencies and the symlinks have been created (inside `node_modules/@my-org` folder).
85
+
Notice that the `package-lock.json` has been updated with the `house-helpers` and `motto-helpers` projects dependencies and the symlinks have been created (inside `node_modules/@my-org` folder).
94
86
95
87
> NOTE: also, we only have the root `node_modules` folder and the `package-lock.json` file, not inside each project.
Delete the `package-lock.json` file to force `npm` to create a new one:
143
-
144
-
```bash
145
-
rm package-lock.json
146
-
147
-
```
148
-
149
135
This project has the `house-helpers` project as a dependency because we are sharing the `House` enum type. We are going to install it using the workspace :
150
136
151
137
```bash
@@ -244,13 +230,7 @@ npm install
244
230
Every app will have the `house-helpers` and `motto-helpers` projects as dependencies. Let's install them using the workspace:
If we want to run all the projects at the same time, [npm has some flags](https://docs.npmjs.com/cli/v7/using-npm/workspaces#ignoring-missing-scripts) to run multiple workspaces commands at the same time:
> But it doesn't work if put it in the `package.json` > `scripts` fiel on windows because it using the `cmd` shell by default and it doesn't support the `&` operator.
280
+
292
281
Let's install a third party library [npm-run-all](https://www.npmjs.com/package/npm-run-all) to run commands in parallel:
0 commit comments