Skip to content

Commit

Permalink
docs: refreshed npm updated docs
Browse files Browse the repository at this point in the history
PR-URL: #2558
Credit: @ruyadorno
Close: #2558
Reviewed-by: @wraithgar
  • Loading branch information
ruyadorno authored and nlf committed Jan 28, 2021
1 parent 7772d9f commit 52e8a1a
Showing 1 changed file with 10 additions and 19 deletions.
29 changes: 10 additions & 19 deletions docs/content/commands/npm-update.md
@@ -1,7 +1,7 @@
---
title: npm-update
section: 1
description: Update a package
description: Update packages
---

### Synopsis
Expand All @@ -27,22 +27,11 @@ packages.
If no package name is specified, all packages in the specified location (global
or local) will be updated.

As of `npm@2.6.1`, the `npm update` will only inspect top-level packages.
Prior versions of `npm` would also recursively inspect all dependencies.
To get the old behavior, use `npm --depth 9999 update`.

As of `npm@5.0.0`, the `npm update` will change `package.json` to save the
new version as the minimum required dependency. To get the old behavior,
use `npm update --no-save`.

### Example

IMPORTANT VERSION NOTE: these examples assume `npm@2.6.1` or later. For
older versions of `npm`, you must specify `--depth 0` to get the behavior
described below.

For the examples below, assume that the current package is `app` and it depends
on dependencies, `dep1` (`dep2`, .. etc.). The published versions of `dep1` are:
on dependencies, `dep1` (`dep2`, .. etc.). The published versions of `dep1`
are:

```json
{
Expand Down Expand Up @@ -84,10 +73,10 @@ However, if `app`'s `package.json` contains:
}
```

In this case, running `npm update` will install `dep1@1.1.2`. Even though the `latest`
tag points to `1.2.2`, this version does not satisfy `~1.1.1`, which is equivalent
to `>=1.1.1 <1.2.0`. So the highest-sorting version that satisfies `~1.1.1` is used,
which is `1.1.2`.
In this case, running `npm update` will install `dep1@1.1.2`. Even though the
`latest` tag points to `1.2.2`, this version do not satisfy `~1.1.1`, which is
equivalent to `>=1.1.1 <1.2.0`. So the highest-sorting version that satisfies
`~1.1.1` is used, which is `1.1.2`.

#### Caret Dependencies below 1.0.0

Expand Down Expand Up @@ -120,7 +109,9 @@ version that satisfies `^0.4.0` (`>= 0.4.0 <0.5.0`)
package that is `outdated` -- that is, has a version that is different from
`wanted`.

Note: Globally installed packages are treated as if they are installed with a caret semver range specified. So if you require to update to `latest` you may need to run `npm install -g [<pkg>...]`
Note: Globally installed packages are treated as if they are installed with a
caret semver range specified. So if you require to update to `latest` you may
need to run `npm install -g [<pkg>...]`

NOTE: If a package has been upgraded to a version newer than `latest`, it will
be _downgraded_.
Expand Down

0 comments on commit 52e8a1a

Please sign in to comment.