Skip to content

Commit f47e427

Browse files
committed
format
1 parent 9cdf558 commit f47e427

File tree

1 file changed

+35
-10
lines changed

1 file changed

+35
-10
lines changed

docs/how-to-update-npm-packages.md

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,36 @@
11
# How to update NPM packages
22

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.
47

58
## Install npm-check-updates
9+
610
```sh
711
npm i -D npm-check-updates
812
```
913

1014
## 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.
1219

1320
```sh
1421
npx ncu
1522
```
1623

1724
Notice the colors:
25+
1826
- Green = (nonmajor version zero) patch updates
1927
- Cyan = minor updates
2028
- Red = major or [version zero (0.y.z)](https://semver.org/#spec-item-4) updates
2129

2230
## Update green patch versions first, all at once
2331

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,
33+
it's ok to update them all at once.
2534

2635
```sh
2736
npx ncu -u -filter <package-with-green-patch-update>
@@ -31,9 +40,14 @@ npx ncu -u -filter <package-with-green-patch-update>
3140
npm i
3241
```
3342

34-
> 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.
3547
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.
48+
Assuming package maintainers follow semantic versioning, updating patch versions
49+
shouldn't break anything, but it's good practice to re-run your tests before
50+
committing these changes.
3751

3852
```sh
3953
npm run test
@@ -48,18 +62,25 @@ git commit -m "Updated patch versions"
4862

4963
## Update cyan minor versions second, one by one
5064

51-
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.
5269

5370
To check for the new package's features, check its release notes on GitHub.
5471

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.
5675
5776
```sh
5877
npx ncu -u -filter <package-with-cyan-minor-update>
5978
npm i
6079
```
6180

62-
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.
81+
Again, assuming package maintainers follow semantic versioning updating patch
82+
versions shouldn't break anything, but it's good practice to re-run your tests
83+
to make sure.
6384

6485
```sh
6586
npm run test
@@ -74,9 +95,13 @@ git commit -m "Updated minor versions"
7495

7596
## Update red versions third, one by one
7697

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.
78102

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.
80105
81106
```sh
82107
npx ncu -u -f <package-with-red-version-update>

0 commit comments

Comments
 (0)