Select CLI Version:
See DetailsTable of contentsSynopsis npm update [...] aliases: up, upgrade, udpate DescriptionThis command will update all the packages listed to the latest version (specified by the tag config), respecting the semver constraints of both your package and its dependencies (if they also require the same package).
It will also install missing packages.
If the -g flag is specified, this command will update globally installed packages.
If no package name is specified, all packages in the specified location (global or local) will be updated.
Note that by default npm update will not update the semver values of direct dependencies in your project package.json, if you want to also update values in package.json you can run: npm update --se (or add the se=true option to a configuration file to make that the default behior).
ExampleFor the examples below, assume that the current package is app and it depends on dependencies, dep1 (dep2, .. etc.). The published versions of dep1 are:
{ "dist-tags": { "latest": "1.2.2" }, "versions": [ "1.2.2", "1.2.1", "1.2.0", "1.1.2", "1.1.1", "1.0.0", "0.4.1", "0.4.0", "0.2.0" ]} Caret DependenciesIf app's package.json contains:
"dependencies": { "dep1": "^1.1.1"}Then npm update will install dep1@1.2.2, because 1.2.2 is latest and 1.2.2 satisfies ^1.1.1.
Tilde DependenciesHowever, if app's package.json contains:
"dependencies": { "dep1": "~1.1.1"}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 = 0.4.0