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: npm-shrinkwrap.readme.md
+14-26Lines changed: 14 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,31 +3,23 @@ All of our npm dependencies are locked via the `npm-shrinkwrap.json` file for th
3
3
- our project has lots of dependencies which update at unpredictable times, so it's important that
4
4
we update them explicitly once in a while rather than implicitly when any of us runs npm install
5
5
- locked dependencies allow us to do reuse npm cache on travis, significantly speeding up our builds
6
-
(by 5min or more)
6
+
(by 5 minutes or more)
7
7
- locked dependencies allow us to detect when node_modules folder is out of date after a branch switch
8
8
which allows us to build the project with the correct dependencies every time
9
9
10
-
However npm's shrinkwrap is known to be buggy, so we need to take some extra steps to deal with this.
11
-
The most important step is generating the npm-shrinkwrap.clean.js which is used during code reviews
12
-
or debugging to easily review what has actually changed.
13
-
See https://github.com/npm/npm/issues/3581 for related npm issue. A common symptom is that the `from`
14
-
property of various dependencies in `npm-shrinkwrap.json` "arbitrarily" changes depending on when and
15
-
where the shrinkwrap command was run.
10
+
We also generate `npm-shrinkwrap.clean.js` file which is used during code reviews or debugging to easily review what has actually changed without extra noise.
16
11
17
12
To add a new dependency do the following:
18
13
19
14
1. if you are on linux or windows, then use MacOS or ask someone with MacOS to perform the
20
15
installation. This is due to an optional `fsevents` dependency that is really required on MacOS
21
16
to get good performance from file watching.
22
17
2. make sure you are in sync with `upstream/master`
23
-
3. ensure that your `node_modules` directory is not stale or poisoned by doing a clean install with
24
-
`rm -rf node_modules && npm install`
18
+
3. ensure that your `node_modules` directory is not stale by running `npm install`
25
19
4. add a new dependency via `npm install --save-dev <packagename>`
26
-
5. update npm-shrinkwrap.json with `npm shrinkwrap --dev`
27
-
6. run `./tools/npm/clean-shrinkwrap.js`
28
-
7. these steps should change 3 files: `package.json`, `npm-shrinkwrap.json` and
29
-
`npm-shrinkwrap.clean.json`
30
-
8. commit changes to these three files and you are done
20
+
5. run `./tools/npm/reshrinkwrap`
21
+
6. these steps should change 3 files: `package.json`, `npm-shrinkwrap.json` and `npm-shrinkwrap.clean.json`
22
+
7. commit changes to these three files and you are done
31
23
32
24
33
25
To update existing dependency do the following:
@@ -36,16 +28,14 @@ To update existing dependency do the following:
36
28
installation. This is due to an optional `fsevents` dependency that is really required on MacOS
37
29
to get good performance from file watching.
38
30
2. make sure you are in sync with `upstream/master`: `git fetch upstream && git rebase upstream/master`
39
-
3. ensure that your `node_modules` directory is not stale or poisoned by doing a clean install with
40
-
`rm -rf node_modules && npm install`
31
+
3. ensure that your `node_modules` directory is not stale by running `npm install`
41
32
4. run `npm install --save-dev <packagename>@<version|latest>` or `npm update <packagename>` to
42
33
update to the latest version that matches version constraint in `package.json`
43
-
5. relock the dependencies with `npm shrinkwrap --dev`
44
-
6. clean up the shrinkwrap file for review with `./tools/npm/clean-shrinkwrap.js`
45
-
7. these steps should change 2 files: `npm-shrinkwrap.json` and `npm-shrinkwrap.clean.json`.
34
+
5. run `./tools/npm/reshrinkwrap`
35
+
6. these steps should change 2 files: `npm-shrinkwrap.json` and `npm-shrinkwrap.clean.json`.
46
36
Optionally if you used `npm install ...` in the first step, `package.json` might be modified as
47
37
well.
48
-
8. commit changes to these three files and you are done
38
+
7. commit changes to these three files and you are done
49
39
50
40
51
41
To Remove an existing dependency do the following:
@@ -54,10 +44,8 @@ To Remove an existing dependency do the following:
54
44
installation. This is due to an optional `fsevents` dependency that is really required on MacOS
55
45
to get good performance from file watching.
56
46
2. make sure you are in sync with `upstream/master`: `git fetch upstream && git rebase upstream/master`
57
-
3. ensure that your `node_modules` directory is not stale or poisoned by doing a clean install with
58
-
`rm -rf node_modules && npm install`
47
+
3. ensure that your `node_modules` directory is not stale by running `npm install`
59
48
4. run `npm uninstall --save-dev <packagename>@<version|latest>`
60
-
5. relock the dependencies with `npm shrinkwrap --dev`
61
-
6. clean up the shrinkwrap file for review with `./tools/npm/clean-shrinkwrap.js`
62
-
7. these steps should change 3 files: `npm-shrinkwrap.json` and `npm-shrinkwrap.clean.json`.
63
-
8. commit changes to these three files and you are done
49
+
5. run `./tools/npm/reshrinkwrap`
50
+
6. these steps should change 3 files: `npm-shrinkwrap.json` and `npm-shrinkwrap.clean.json`.
51
+
7. commit changes to these three files and you are done
0 commit comments