404

[ Avaa Bypassed ]




Upload:

Command:

botdev@18.191.130.191: ~ $
---
section: cli-commands 
title: npm-update
description: Update a package
---

# npm-update(1)

## Update a package

### Synopsis

```bash
npm update [-g] [<pkg>...]

aliases: up, upgrade
```

### Description

This command will update all the packages listed to the latest version
(specified by the `tag` config), respecting semver.

It will also install missing packages. As with all commands that install
packages, the `--dev` flag will cause `devDependencies` to be processed
as well.

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.

As of `npm@2.6.1`, 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 `npm@5.0.0`, 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 `npm@2.6.1` 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:

```json
{
  "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 Dependencies

If `app`'s `package.json` contains:

```json
"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 Dependencies

However, if `app`'s `package.json` contains:

```json
"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 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`.

#### Caret Dependencies below 1.0.0

Suppose `app` has a caret dependency on a version below `1.0.0`, for example:

```json
"dependencies": {
  "dep1": "^0.2.0"
}
```

`npm update` will install `dep1@0.2.0`, because there are no other
versions which satisfy `^0.2.0`.

If the dependence were on `^0.4.0`:

```json
"dependencies": {
  "dep1": "^0.4.0"
}
```

Then `npm update` will install `dep1@0.4.1`, because that is the highest-sorting
version that satisfies `^0.4.0` (`>= 0.4.0 <0.5.0`)


#### Updating Globally-Installed Packages

`npm update -g` will apply the `update` action to each globally installed
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: If a package has been upgraded to a version newer than `latest`, it will
be _downgraded_.


### See Also

* [npm install](/cli-commands/npm-install)
* [npm outdated](/cli-commands/npm-outdated)
* [npm shrinkwrap](/cli-commands/npm-shrinkwrap)
* [npm registry](/using-npm/registry)
* [npm folders](/configuring-npm/folders)
* [npm ls](/cli-commands/npm-ls)

Filemanager

Name Type Size Permission Actions
npm-access.md File 2.87 KB 0644
npm-adduser.md File 2.93 KB 0644
npm-audit.md File 4.08 KB 0644
npm-bin.md File 452 B 0644
npm-bugs.md File 1.08 KB 0644
npm-build.md File 645 B 0644
npm-bundle.md File 416 B 0644
npm-cache.md File 2.73 KB 0644
npm-ci.md File 1.92 KB 0644
npm-completion.md File 936 B 0644
npm-config.md File 1.62 KB 0644
npm-dedupe.md File 1.44 KB 0644
npm-deprecate.md File 953 B 0644
npm-dist-tag.md File 2.95 KB 0644
npm-docs.md File 1.14 KB 0644
npm-doctor.md File 4.65 KB 0644
npm-edit.md File 1.07 KB 0644
npm-explore.md File 1.04 KB 0644
npm-fund.md File 1.59 KB 0644
npm-help-search.md File 910 B 0644
npm-help.md File 989 B 0644
npm-hook.md File 1.88 KB 0644
npm-init.md File 2.17 KB 0644
npm-install-ci-test.md File 438 B 0644
npm-install-test.md File 832 B 0644
npm-install.md File 19.03 KB 0644
npm-link.md File 2.75 KB 0644
npm-logout.md File 1.28 KB 0644
npm-ls.md File 2.57 KB 0644
npm-org.md File 1.01 KB 0644
npm-outdated.md File 3.86 KB 0644
npm-owner.md File 1.22 KB 0644
npm-pack.md File 1.01 KB 0644
npm-ping.md File 519 B 0644
npm-prefix.md File 678 B 0644
npm-profile.md File 2.89 KB 0644
npm-prune.md File 1.38 KB 0644
npm-publish.md File 3.12 KB 0644
npm-rebuild.md File 495 B 0644
npm-repo.md File 774 B 0644
npm-restart.md File 962 B 0644
npm-root.md File 438 B 0644
npm-run-script.md File 3.49 KB 0644
npm-search.md File 2.85 KB 0644
npm-shrinkwrap.md File 1004 B 0644
npm-star.md File 591 B 0644
npm-stars.md File 614 B 0644
npm-start.md File 798 B 0644
npm-stop.md File 452 B 0644
npm-team.md File 2.2 KB 0644
npm-test.md File 469 B 0644
npm-token.md File 2.8 KB 0644
npm-uninstall.md File 1.53 KB 0644
npm-unpublish.md File 1.45 KB 0644
npm-update.md File 3.39 KB 0644
npm-version.md File 4.47 KB 0644
npm-view.md File 3.19 KB 0644
npm-whoami.md File 385 B 0644
npm.md File 5.31 KB 0644