1 .TH "NPM\-UPDATE" "1" "October 2016" "" ""
3 \fBnpm-update\fR \- Update a package
8 npm update [\-g] [<name> [<name> \.\.\.]]
15 This command will update all the packages listed to the latest version
16 (specified by the \fBtag\fP config), respecting semver\.
18 It will also install missing packages\. As with all commands that install
19 packages, the \fB\-\-dev\fP flag will cause \fBdevDependencies\fP to be processed
22 If the \fB\-g\fP flag is specified, this command will update globally installed
25 If no package name is specified, all packages in the specified location (global
26 or local) will be updated\.
28 As of \fBnpm@2\.6\.1\fP, the \fBnpm update\fP will only inspect top\-level packages\.
29 Prior versions of \fBnpm\fP would also recursively inspect all dependencies\.
30 To get the old behavior, use \fBnpm \-\-depth 9999 update\fP\|\.
33 IMPORTANT VERSION NOTE: these examples assume \fBnpm@2\.6\.1\fP or later\. For
34 older versions of \fBnpm\fP, you must specify \fB\-\-depth 0\fP to get the behavior
37 For the examples below, assume that the current package is \fBapp\fP and it depends
38 on dependencies, \fBdep1\fP (\fBdep2\fP, \.\. etc\.)\. The published versions of \fBdep1\fP are:
43 "dist\-tags": { "latest": "1\.2\.2" },
58 .SS Caret Dependencies
60 If \fBapp\fP\|'s \fBpackage\.json\fP contains:
70 Then \fBnpm update\fP will install \fBdep1@1\.2\.2\fP, because \fB1\.2\.2\fP is \fBlatest\fP and
71 \fB1\.2\.2\fP satisfies \fB^1\.1\.1\fP\|\.
72 .SS Tilde Dependencies
74 However, if \fBapp\fP\|'s \fBpackage\.json\fP contains:
84 In this case, running \fBnpm update\fP will install \fBdep1@1\.1\.2\fP\|\. Even though the \fBlatest\fP
85 tag points to \fB1\.2\.2\fP, this version does not satisfy \fB~1\.1\.1\fP, which is equivalent
86 to \fB>=1\.1\.1 <1\.2\.0\fP\|\. So the highest\-sorting version that satisfies \fB~1\.1\.1\fP is used,
87 which is \fB1\.1\.2\fP\|\.
88 .SS Caret Dependencies below 1\.0\.0
90 Suppose \fBapp\fP has a caret dependency on a version below \fB1\.0\.0\fP, for example:
100 \fBnpm update\fP will install \fBdep1@0\.2\.0\fP, because there are no other
101 versions which satisfy \fB^0\.2\.0\fP\|\.
103 If the dependence were on \fB^0\.4\.0\fP:
113 Then \fBnpm update\fP will install \fBdep1@0\.4\.1\fP, because that is the highest\-sorting
114 version that satisfies \fB^0\.4\.0\fP (\fB>= 0\.4\.0 <0\.5\.0\fP)
115 .SS Recording Updates with \fB\-\-save\fP
117 When you want to update a package and save the new version as
118 the minimum required dependency in \fBpackage\.json\fP, you can use
119 \fBnpm update \-\-save\fP\|\. For example if \fBpackage\.json\fP contains
129 Then \fBnpm update \-\-save\fP will install \fBdep1@1\.2\.2\fP (i\.e\., \fBlatest\fP),
130 and \fBpackage\.json\fP will be modified:
140 Note that \fBnpm\fP will only write an updated version to \fBpackage\.json\fP
141 if it installs a new package\.
142 .SS Updating Globally\-Installed Packages
144 \fBnpm update \-g\fP will apply the \fBupdate\fP action to each globally installed
145 package that is \fBoutdated\fP \-\- that is, has a version that is different from
148 NOTE: If a package has been upgraded to a version newer than \fBlatest\fP, it will
149 be \fIdowngraded\fR\|\.