1NPM-UPDATE(1) NPM-UPDATE(1)
2
3
4
6 npm-update - Update a package
7
9 npm update [-g] [<pkg>...]
10
11 aliases: up, upgrade
12
14 This command will update all the packages listed to the latest version
15 (specified by the tag config), respecting semver.
16
17 It will also install missing packages. As with all commands that
18 install packages, the --dev flag will cause devDependencies to be pro‐
19 cessed as well.
20
21 If the -g flag is specified, this command will update globally
22 installed packages.
23
24 If no package name is specified, all packages in the specified location
25 (global or local) will be updated.
26
27 As of npm@2.6.1, the npm update will only inspect top-level packages.
28 Prior versions of npm would also recursively inspect all dependencies.
29 To get the old behavior, use npm --depth 9999 update.
30
31 As of npm@5.0.0, the npm update will change package.json to save the
32 new version as the minimum required dependency. To get the old behav‐
33 ior, use npm update --no-save.
34
36 IMPORTANT VERSION NOTE: these examples assume npm@2.6.1 or later. For
37 older versions of npm, you must specify --depth 0 to get the behavior
38 described below.
39
40 For the examples below, assume that the current package is app and it
41 depends on dependencies, dep1 (dep2, .. etc.). The published versions
42 of dep1 are:
43
44 {
45 "dist-tags": { "latest": "1.2.2" },
46 "versions": [
47 "1.2.2",
48 "1.2.1",
49 "1.2.0",
50 "1.1.2",
51 "1.1.1",
52 "1.0.0",
53 "0.4.1",
54 "0.4.0",
55 "0.2.0"
56 ]
57 }
58
59 Caret Dependencies
60 If app's package.json contains:
61
62 "dependencies": {
63 "dep1": "^1.1.1"
64 }
65
66 Then npm update will install dep1@1.2.2, because 1.2.2 is latest and
67 1.2.2 satisfies ^1.1.1.
68
69 Tilde Dependencies
70 However, if app's package.json contains:
71
72 "dependencies": {
73 "dep1": "~1.1.1"
74 }
75
76 In this case, running npm update will install dep1@1.1.2. Even though
77 the latest tag points to 1.2.2, this version does not satisfy ~1.1.1,
78 which is equivalent to >=1.1.1 <1.2.0. So the highest-sorting version
79 that satisfies ~1.1.1 is used, which is 1.1.2.
80
81 Caret Dependencies below 1.0.0
82 Suppose app has a caret dependency on a version below 1.0.0, for exam‐
83 ple:
84
85 "dependencies": {
86 "dep1": "^0.2.0"
87 }
88
89 npm update will install dep1@0.2.0, because there are no other versions
90 which satisfy ^0.2.0.
91
92 If the dependence were on ^0.4.0:
93
94 "dependencies": {
95 "dep1": "^0.4.0"
96 }
97
98 Then npm update will install dep1@0.4.1, because that is the high‐
99 est-sorting version that satisfies ^0.4.0 (>= 0.4.0 <0.5.0)
100
101 Updating Globally-Installed Packages
102 npm update -g will apply the update action to each globally installed
103 package that is outdated -- that is, has a version that is different
104 from latest.
105
106 NOTE: If a package has been upgraded to a version newer than latest, it
107 will be downgraded.
108
110 · npm help install
111
112 · npm help outdated
113
114 · npm help shrinkwrap
115
116 · npm help 7 registry
117
118 · npm help 5 folders
119
120 · npm help ls
121
122
123
124
125
126 October 2019 NPM-UPDATE(1)