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/how-to-update-npm-packages.md
+35-10Lines changed: 35 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,27 +1,36 @@
1
1
# How to update NPM packages
2
2
3
-
It’s important to update your packages to get new features, bug fixes, and security patches. [NPM Check Updates](https://www.npmjs.com/package/npm-check-updates) is a CLI that will help you safely make those updates.
3
+
It’s important to update your packages to get new features, bug fixes, and
4
+
security patches.
5
+
[NPM Check Updates](https://www.npmjs.com/package/npm-check-updates) is a CLI
6
+
that will help you safely make those updates.
4
7
5
8
## Install npm-check-updates
9
+
6
10
```sh
7
11
npm i -D npm-check-updates
8
12
```
9
13
10
14
## See a list of packages that can be updated
11
-
NPM packages follow [semantic versioning](https://semver.org). This command will show you which packages can be updated and which major, minor, or patch versions are available.
15
+
16
+
NPM packages follow [semantic versioning](https://semver.org). This command will
17
+
show you which packages can be updated and which major, minor, or patch versions
18
+
are available.
12
19
13
20
```sh
14
21
npx ncu
15
22
```
16
23
17
24
Notice the colors:
25
+
18
26
- Green = (nonmajor version zero) patch updates
19
27
- Cyan = minor updates
20
28
- Red = major or [version zero (0.y.z)](https://semver.org/#spec-item-4) updates
21
29
22
30
## Update green patch versions first, all at once
23
31
24
-
Since green patch version updates are meant for backward-compatible bug fixes, it's ok to update them all at once.
32
+
Since green patch version updates are meant for backward-compatible bug fixes,
> Note: `npx ncu -u -t patch` updates all patch versions, including major version zero patch versions, which can break your code. If all your patch updates are green, feel free to use this command instead to update them all at once.
43
+
> Note: `npx ncu -u -t patch` updates all patch versions, including major
44
+
> version zero patch versions, which can break your code. If all your patch
45
+
> updates are green, feel free to use this command instead to update them all at
46
+
> once.
35
47
36
-
Assuming package maintainers follow semantic versioning, updating patch versions shouldn't break anything, but it's good practice to re-run your tests before committing these changes.
Minor version updates introduce new features in a backward-compatible way. This is exciting and it's good practice to take some time to explore the new functionality and apply relevant updates to your code base or plan to apply them later. It's recommended you do this package by package instead of all at once.
65
+
Minor version updates introduce new features in a backward-compatible way. This
66
+
is exciting and it's good practice to take some time to explore the new
67
+
functionality and apply relevant updates to your code base or plan to apply them
68
+
later. It's recommended you do this package by package instead of all at once.
52
69
53
70
To check for the new package's features, check its release notes on GitHub.
54
71
55
-
> If you haven't updated a fairly active package in a while, reading all its release notes can take some time. Take into consideration how important a package is for your project when choosing which to update first.
72
+
> If you haven't updated a fairly active package in a while, reading all its
73
+
> release notes can take some time. Take into consideration how important a
74
+
> package is for your project when choosing which to update first.
Again, assuming package maintainers follow semantic versioning updating patch versions shouldn't break anything, but it's good practice to re-run your tests to make sure.
versions shouldn't break anything, but it's good practice to re-run your tests
83
+
to make sure.
63
84
64
85
```sh
65
86
npm run test
@@ -74,9 +95,13 @@ git commit -m "Updated minor versions"
74
95
75
96
## Update red versions third, one by one
76
97
77
-
Red updates can happen on patch or minor versions (for zero major version (0.y.z) packages) or major versions. Either way, they could be breaking changes. It's recommended you read its release notes to see what changed and plan accordingly.
98
+
Red updates can happen on patch or minor versions (for zero major version
99
+
(0.y.z) packages) or major versions. Either way, they could be breaking changes.
100
+
It's recommended you read its release notes to see what changed and plan
101
+
accordingly.
78
102
79
-
> Again, you might want to take into consideration how important a package is for your project when choosing which to update first.
103
+
> Again, you might want to take into consideration how important a package is
104
+
> for your project when choosing which to update first.
0 commit comments