-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PR-URL: #2558 Credit: @ruyadorno Close: #2558 Reviewed-by: @wraithgar
- Loading branch information
Showing
1 changed file
with
10 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
--- | ||
title: npm-update | ||
section: 1 | ||
description: Update a package | ||
description: Update packages | ||
--- | ||
|
||
### Synopsis | ||
|
@@ -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 `[email protected]`, 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 `[email protected]`, 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 `[email protected]` 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 | ||
{ | ||
|
@@ -84,10 +73,10 @@ However, if `app`'s `package.json` contains: | |
} | ||
``` | ||
|
||
In this case, running `npm update` will install `[email protected]`. 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 `[email protected]`. 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 | ||
|
||
|
@@ -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_. | ||
|