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
npm outdated
Compares installed versions against the registry and reports which packages have a newer version available in current/wanted/latest columns. `wanted` respects your semver range, `latest` is the newest published.
npm install
Installs a package (and its dependencies), adding it to package.json and refreshing package-lock.json. Without arguments, installs everything already declared in the current project's package.json.
npm view (info)
Fetches package metadata straight from the registry — versions, maintainers, dist-tags, dependencies, and more. Aliases: `info`, `show`, `v`.
npm install --global
Installs a package into the global prefix so its bin scripts are on your PATH system-wide. Global installs live outside any project's node_modules.
npm ci
Performs a clean, deterministic install straight from package-lock.json (or npm-shrinkwrap.json) intended for CI environments. It deletes any existing node_modules and refuses to run if package.json and the lockfile are out of sync.