install

npm update

Updates packages to the newest version that still satisfies the semver range in package.json and refreshes package-lock.json. Without arguments, it tries every listed dependency.

npm update [<pkg>...] [--save] [--global]

Common flags

Flag Purpose
--save Also bump the range in package.json to the new resolved version
--global (-g) Update globally-installed packages
--depth <n> How deep in the tree to update (default 0 in npm 7+)
--dev Restrict to devDependencies

Examples

npm update

Update all deps within their semver ranges

npm update react

Update only react within its ^ range

npm update -g

Update all globally-installed packages

Gotcha

`npm update` will NOT cross a major-version boundary — for that use `npm install pkg@latest` or a tool like `npm-check-updates`. Preview what would change first with `npm outdated`.

Related commands

← All npm commands · npm vs pnpm vs Yarn · Fix Node OOM