npm-update.1 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465
  1. .TH "NPM\-UPDATE" "1" "October 2021" "" ""
  2. .SH "NAME"
  3. \fBnpm-update\fR \- Update packages
  4. .SS Synopsis
  5. .P
  6. .RS 2
  7. .nf
  8. npm update [\-g] [<pkg>\.\.\.]
  9. aliases: up, upgrade
  10. .fi
  11. .RE
  12. .SS Description
  13. .P
  14. This command will update all the packages listed to the latest version
  15. (specified by the \fBtag\fP config), respecting the semver constraints of
  16. both your package and its dependencies (if they also require the same
  17. package)\.
  18. .P
  19. It will also install missing packages\.
  20. .P
  21. If the \fB\-g\fP flag is specified, this command will update globally installed
  22. packages\.
  23. .P
  24. If no package name is specified, all packages in the specified location (global
  25. or local) will be updated\.
  26. .SS Example
  27. .P
  28. For the examples below, assume that the current package is \fBapp\fP and it depends
  29. on dependencies, \fBdep1\fP (\fBdep2\fP, \.\. etc\.)\. The published versions of \fBdep1\fP
  30. are:
  31. .P
  32. .RS 2
  33. .nf
  34. {
  35. "dist\-tags": { "latest": "1\.2\.2" },
  36. "versions": [
  37. "1\.2\.2",
  38. "1\.2\.1",
  39. "1\.2\.0",
  40. "1\.1\.2",
  41. "1\.1\.1",
  42. "1\.0\.0",
  43. "0\.4\.1",
  44. "0\.4\.0",
  45. "0\.2\.0"
  46. ]
  47. }
  48. .fi
  49. .RE
  50. .SS Caret Dependencies
  51. .P
  52. If \fBapp\fP\|'s \fBpackage\.json\fP contains:
  53. .P
  54. .RS 2
  55. .nf
  56. "dependencies": {
  57. "dep1": "^1\.1\.1"
  58. }
  59. .fi
  60. .RE
  61. .P
  62. Then \fBnpm update\fP will install \fBdep1@1\.2\.2\fP, because \fB1\.2\.2\fP is \fBlatest\fP and
  63. \fB1\.2\.2\fP satisfies \fB^1\.1\.1\fP\|\.
  64. .SS Tilde Dependencies
  65. .P
  66. However, if \fBapp\fP\|'s \fBpackage\.json\fP contains:
  67. .P
  68. .RS 2
  69. .nf
  70. "dependencies": {
  71. "dep1": "~1\.1\.1"
  72. }
  73. .fi
  74. .RE
  75. .P
  76. In this case, running \fBnpm update\fP will install \fBdep1@1\.1\.2\fP\|\. Even though the
  77. \fBlatest\fP tag points to \fB1\.2\.2\fP, this version do not satisfy \fB~1\.1\.1\fP, which is
  78. equivalent to \fB>=1\.1\.1 <1\.2\.0\fP\|\. So the highest\-sorting version that satisfies
  79. \fB~1\.1\.1\fP is used, which is \fB1\.1\.2\fP\|\.
  80. .SS Caret Dependencies below 1\.0\.0
  81. .P
  82. Suppose \fBapp\fP has a caret dependency on a version below \fB1\.0\.0\fP, for example:
  83. .P
  84. .RS 2
  85. .nf
  86. "dependencies": {
  87. "dep1": "^0\.2\.0"
  88. }
  89. .fi
  90. .RE
  91. .P
  92. \fBnpm update\fP will install \fBdep1@0\.2\.0\fP, because there are no other
  93. versions which satisfy \fB^0\.2\.0\fP\|\.
  94. .P
  95. If the dependence were on \fB^0\.4\.0\fP:
  96. .P
  97. .RS 2
  98. .nf
  99. "dependencies": {
  100. "dep1": "^0\.4\.0"
  101. }
  102. .fi
  103. .RE
  104. .P
  105. Then \fBnpm update\fP will install \fBdep1@0\.4\.1\fP, because that is the highest\-sorting
  106. version that satisfies \fB^0\.4\.0\fP (\fB>= 0\.4\.0 <0\.5\.0\fP)
  107. .SS Subdependencies
  108. .P
  109. Suppose your app now also has a dependency on \fBdep2\fP
  110. .P
  111. .RS 2
  112. .nf
  113. {
  114. "name": "my\-app",
  115. "dependencies": {
  116. "dep1": "^1\.0\.0",
  117. "dep2": "1\.0\.0"
  118. }
  119. }
  120. .fi
  121. .RE
  122. .P
  123. and \fBdep2\fP itself depends on this limited range of \fBdep1\fP
  124. .P
  125. .RS 2
  126. .nf
  127. {
  128. "name": "dep2",
  129. "dependencies": {
  130. "dep1": "~1\.1\.1"
  131. }
  132. }
  133. .fi
  134. .RE
  135. .P
  136. Then \fBnpm update\fP will install \fBdep1@1\.1\.2\fP because that is the highest
  137. version that \fBdep2\fP allows\. npm will prioritize having a single version
  138. of \fBdep1\fP in your tree rather than two when that single version can
  139. satisfy the semver requirements of multiple dependencies in your tree\.
  140. In this case if you really did need your package to use a newer version
  141. you would need to use \fBnpm install\fP\|\.
  142. .SS Updating Globally\-Installed Packages
  143. .P
  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
  146. \fBwanted\fP\|\.
  147. .P
  148. Note: Globally installed packages are treated as if they are installed with a
  149. caret semver range specified\. So if you require to update to \fBlatest\fP you may
  150. need to run \fBnpm install \-g [<pkg>\.\.\.]\fP
  151. .P
  152. NOTE: If a package has been upgraded to a version newer than \fBlatest\fP, it will
  153. be \fIdowngraded\fR\|\.
  154. .SS Configuration
  155. <!\-\- AUTOGENERATED CONFIG DESCRIPTIONS START \-\->
  156. <!\-\- automatically generated, do not edit manually \-\->
  157. <!\-\- see lib/utils/config/definitions\.js \-\->
  158. .SS \fBglobal\fP
  159. .RS 0
  160. .IP \(bu 2
  161. Default: false
  162. .IP \(bu 2
  163. Type: Boolean
  164. .RE
  165. .P
  166. Operates in "global" mode, so that packages are installed into the \fBprefix\fP
  167. folder instead of the current working directory\. See
  168. npm help folders for more on the differences in behavior\.
  169. .RS 0
  170. .IP \(bu 2
  171. packages are installed into the \fB{prefix}/lib/node_modules\fP folder, instead
  172. of the current working directory\.
  173. .IP \(bu 2
  174. bin files are linked to \fB{prefix}/bin\fP
  175. .IP \(bu 2
  176. man pages are linked to \fB{prefix}/share/man\fP
  177. .RE
  178. <!\-\- automatically generated, do not edit manually \-\->
  179. <!\-\- see lib/utils/config/definitions\.js \-\->
  180. .SS \fBglobal\-style\fP
  181. .RS 0
  182. .IP \(bu 2
  183. Default: false
  184. .IP \(bu 2
  185. Type: Boolean
  186. .RE
  187. .P
  188. Causes npm to install the package into your local \fBnode_modules\fP folder with
  189. the same layout it uses with the global \fBnode_modules\fP folder\. Only your
  190. direct dependencies will show in \fBnode_modules\fP and everything they depend
  191. on will be flattened in their \fBnode_modules\fP folders\. This obviously will
  192. eliminate some deduping\. If used with \fBlegacy\-bundling\fP, \fBlegacy\-bundling\fP
  193. will be preferred\.
  194. <!\-\- automatically generated, do not edit manually \-\->
  195. <!\-\- see lib/utils/config/definitions\.js \-\->
  196. .SS \fBlegacy\-bundling\fP
  197. .RS 0
  198. .IP \(bu 2
  199. Default: false
  200. .IP \(bu 2
  201. Type: Boolean
  202. .RE
  203. .P
  204. Causes npm to install the package such that versions of npm prior to 1\.4,
  205. such as the one included with node 0\.8, can install the package\. This
  206. eliminates all automatic deduping\. If used with \fBglobal\-style\fP this option
  207. will be preferred\.
  208. <!\-\- automatically generated, do not edit manually \-\->
  209. <!\-\- see lib/utils/config/definitions\.js \-\->
  210. .SS \fBstrict\-peer\-deps\fP
  211. .RS 0
  212. .IP \(bu 2
  213. Default: false
  214. .IP \(bu 2
  215. Type: Boolean
  216. .RE
  217. .P
  218. If set to \fBtrue\fP, and \fB\-\-legacy\-peer\-deps\fP is not set, then \fIany\fR
  219. conflicting \fBpeerDependencies\fP will be treated as an install failure, even
  220. if npm could reasonably guess the appropriate resolution based on non\-peer
  221. dependency relationships\.
  222. .P
  223. By default, conflicting \fBpeerDependencies\fP deep in the dependency graph will
  224. be resolved using the nearest non\-peer dependency specification, even if
  225. doing so will result in some packages receiving a peer dependency outside
  226. the range set in their package's \fBpeerDependencies\fP object\.
  227. .P
  228. When such and override is performed, a warning is printed, explaining the
  229. conflict and the packages involved\. If \fB\-\-strict\-peer\-deps\fP is set, then
  230. this warning is treated as a failure\.
  231. <!\-\- automatically generated, do not edit manually \-\->
  232. <!\-\- see lib/utils/config/definitions\.js \-\->
  233. .SS \fBpackage\-lock\fP
  234. .RS 0
  235. .IP \(bu 2
  236. Default: true
  237. .IP \(bu 2
  238. Type: Boolean
  239. .RE
  240. .P
  241. If set to false, then ignore \fBpackage\-lock\.json\fP files when installing\. This
  242. will also prevent \fIwriting\fR \fBpackage\-lock\.json\fP if \fBsave\fP is true\.
  243. .P
  244. When package package\-locks are disabled, automatic pruning of extraneous
  245. modules will also be disabled\. To remove extraneous modules with
  246. package\-locks disabled use \fBnpm prune\fP\|\.
  247. <!\-\- automatically generated, do not edit manually \-\->
  248. <!\-\- see lib/utils/config/definitions\.js \-\->
  249. .SS \fBomit\fP
  250. .RS 0
  251. .IP \(bu 2
  252. Default: 'dev' if the \fBNODE_ENV\fP environment variable is set to
  253. \|'production', otherwise empty\.
  254. .IP \(bu 2
  255. Type: "dev", "optional", or "peer" (can be set multiple times)
  256. .RE
  257. .P
  258. Dependency types to omit from the installation tree on disk\.
  259. .P
  260. Note that these dependencies \fIare\fR still resolved and added to the
  261. \fBpackage\-lock\.json\fP or \fBnpm\-shrinkwrap\.json\fP file\. They are just not
  262. physically installed on disk\.
  263. .P
  264. If a package type appears in both the \fB\-\-include\fP and \fB\-\-omit\fP lists, then
  265. it will be included\.
  266. .P
  267. If the resulting omit list includes \fB\|'dev'\fP, then the \fBNODE_ENV\fP environment
  268. variable will be set to \fB\|'production'\fP for all lifecycle scripts\.
  269. <!\-\- automatically generated, do not edit manually \-\->
  270. <!\-\- see lib/utils/config/definitions\.js \-\->
  271. .SS \fBignore\-scripts\fP
  272. .RS 0
  273. .IP \(bu 2
  274. Default: false
  275. .IP \(bu 2
  276. Type: Boolean
  277. .RE
  278. .P
  279. If true, npm does not run scripts specified in package\.json files\.
  280. .P
  281. Note that commands explicitly intended to run a particular script, such as
  282. \fBnpm start\fP, \fBnpm stop\fP, \fBnpm restart\fP, \fBnpm test\fP, and \fBnpm run\-script\fP
  283. will still run their intended script if \fBignore\-scripts\fP is set, but they
  284. will \fInot\fR run any pre\- or post\-scripts\.
  285. <!\-\- automatically generated, do not edit manually \-\->
  286. <!\-\- see lib/utils/config/definitions\.js \-\->
  287. .SS \fBaudit\fP
  288. .RS 0
  289. .IP \(bu 2
  290. Default: true
  291. .IP \(bu 2
  292. Type: Boolean
  293. .RE
  294. .P
  295. When "true" submit audit reports alongside the current npm command to the
  296. default registry and all registries configured for scopes\. See the
  297. documentation for npm help \fBaudit\fP for details on what is
  298. submitted\.
  299. <!\-\- automatically generated, do not edit manually \-\->
  300. <!\-\- see lib/utils/config/definitions\.js \-\->
  301. .SS \fBbin\-links\fP
  302. .RS 0
  303. .IP \(bu 2
  304. Default: true
  305. .IP \(bu 2
  306. Type: Boolean
  307. .RE
  308. .P
  309. Tells npm to create symlinks (or \fB\|\.cmd\fP shims on Windows) for package
  310. executables\.
  311. .P
  312. Set to false to have it not do this\. This can be used to work around the
  313. fact that some file systems don't support symlinks, even on ostensibly Unix
  314. systems\.
  315. <!\-\- automatically generated, do not edit manually \-\->
  316. <!\-\- see lib/utils/config/definitions\.js \-\->
  317. .SS \fBfund\fP
  318. .RS 0
  319. .IP \(bu 2
  320. Default: true
  321. .IP \(bu 2
  322. Type: Boolean
  323. .RE
  324. .P
  325. When "true" displays the message at the end of each \fBnpm install\fP
  326. acknowledging the number of dependencies looking for funding\. See npm help \fBnpm
  327. fund\fP for details\.
  328. <!\-\- automatically generated, do not edit manually \-\->
  329. <!\-\- see lib/utils/config/definitions\.js \-\->
  330. .SS \fBdry\-run\fP
  331. .RS 0
  332. .IP \(bu 2
  333. Default: false
  334. .IP \(bu 2
  335. Type: Boolean
  336. .RE
  337. .P
  338. Indicates that you don't want npm to make any changes and that it should
  339. only report what it would have done\. This can be passed into any of the
  340. commands that modify your local installation, eg, \fBinstall\fP, \fBupdate\fP,
  341. \fBdedupe\fP, \fBuninstall\fP, as well as \fBpack\fP and \fBpublish\fP\|\.
  342. .P
  343. Note: This is NOT honored by other network related commands, eg \fBdist\-tags\fP,
  344. \fBowner\fP, etc\.
  345. <!\-\- automatically generated, do not edit manually \-\->
  346. <!\-\- see lib/utils/config/definitions\.js \-\->
  347. .SS \fBworkspace\fP
  348. .RS 0
  349. .IP \(bu 2
  350. Default:
  351. .IP \(bu 2
  352. Type: String (can be set multiple times)
  353. .RE
  354. .P
  355. Enable running a command in the context of the configured workspaces of the
  356. current project while filtering by running only the workspaces defined by
  357. this configuration option\.
  358. .P
  359. Valid values for the \fBworkspace\fP config are either:
  360. .RS 0
  361. .IP \(bu 2
  362. Workspace names
  363. .IP \(bu 2
  364. Path to a workspace directory
  365. .IP \(bu 2
  366. Path to a parent workspace directory (will result in selecting all
  367. workspaces within that folder)
  368. .RE
  369. .P
  370. When set for the \fBnpm init\fP command, this may be set to the folder of a
  371. workspace which does not yet exist, to create the folder and set it up as a
  372. brand new workspace within the project\.
  373. .P
  374. This value is not exported to the environment for child processes\.
  375. <!\-\- automatically generated, do not edit manually \-\->
  376. <!\-\- see lib/utils/config/definitions\.js \-\->
  377. .SS \fBworkspaces\fP
  378. .RS 0
  379. .IP \(bu 2
  380. Default: null
  381. .IP \(bu 2
  382. Type: null or Boolean
  383. .RE
  384. .P
  385. Set to true to run the command in the context of \fBall\fR configured
  386. workspaces\.
  387. .P
  388. Explicitly setting this to false will cause commands like \fBinstall\fP to
  389. ignore workspaces altogether\. When not set explicitly:
  390. .RS 0
  391. .IP \(bu 2
  392. Commands that operate on the \fBnode_modules\fP tree (install, update, etc\.)
  393. will link workspaces into the \fBnode_modules\fP folder\. \- Commands that do
  394. other things (test, exec, publish, etc\.) will operate on the root project,
  395. \fIunless\fR one or more workspaces are specified in the \fBworkspace\fP config\.
  396. .RE
  397. .P
  398. This value is not exported to the environment for child processes\.
  399. <!\-\- automatically generated, do not edit manually \-\->
  400. <!\-\- see lib/utils/config/definitions\.js \-\->
  401. .SS \fBinclude\-workspace\-root\fP
  402. .RS 0
  403. .IP \(bu 2
  404. Default: false
  405. .IP \(bu 2
  406. Type: Boolean
  407. .RE
  408. .P
  409. Include the workspace root when workspaces are enabled for a command\.
  410. .P
  411. When false, specifying individual workspaces via the \fBworkspace\fP config, or
  412. all workspaces via the \fBworkspaces\fP flag, will cause npm to operate only on
  413. the specified workspaces, and not on the root project\.
  414. <!\-\- automatically generated, do not edit manually \-\->
  415. <!\-\- see lib/utils/config/definitions\.js \-\->
  416. <!\-\- AUTOGENERATED CONFIG DESCRIPTIONS END \-\->
  417. .SS See Also
  418. .RS 0
  419. .IP \(bu 2
  420. npm help install
  421. .IP \(bu 2
  422. npm help outdated
  423. .IP \(bu 2
  424. npm help shrinkwrap
  425. .IP \(bu 2
  426. npm help registry
  427. .IP \(bu 2
  428. npm help folders
  429. .IP \(bu 2
  430. npm help ls
  431. .RE