Next-Gen App & Browser Testing Cloud
Trusted by 2 Mn+ QAs & Devs to accelerate their release cycles

To update dependencies in package.json, run npm outdated to see what is out of date, then npm update to upgrade every package to the newest version allowed by its semver range and refresh package-lock.json. Because npm update never crosses a major version, upgrading everything to the absolute latest, including breaking changes, requires the npm-check-updates tool: run ncu -u to rewrite the ranges, then npm install. Always run your tests afterward to confirm nothing broke.
The key thing to understand is the difference between what your version ranges allow and what the registry actually offers, so let us walk through the commands, semver, and safe upgrade practices.
The package.json file lists your project's packages in two main sections: dependencies, needed to run in production, and devDependencies, needed only during development such as testing frameworks and build tools. Each entry pins a version using semantic versioning (semver), which controls how freely npm may upgrade it. The companion package-lock.json records the exact resolved tree so every install is reproducible.
{
"dependencies": {
"react": "^18.2.0",
"express": "~4.18.2"
},
"devDependencies": {
"cypress": "^13.6.0",
"jest": "^29.7.0"
}
}Start by listing what is out of date. The npm outdated report shows three columns that matter: Current (installed), Wanted (highest version your range allows), and Latest (newest on the registry). When Latest is higher than Wanted, a major upgrade is waiting that npm update will not touch.
# See every package with a newer version available
npm outdated
# Update all packages to the highest "Wanted" version (within semver ranges)
# and refresh package-lock.json
npm update
# Also bump the ranges written in package.json, not just the lockfile
npm update --save
# Update a single package
npm update react
# Force a specific package to its absolute latest, editing package.json
npm install react@latestWhen you want the absolute latest of everything, ignoring existing ranges, use the npm-check-updates (ncu) tool. It rewrites the version ranges in package.json to the latest published versions, even across major boundaries. It does not install, so you run npm install afterward to update the lockfile:
# Install the tool globally
npm install -g npm-check-updates
# Preview which ranges would change
ncu
# Rewrite package.json ranges to the latest versions
ncu -u
# Apply the new versions to node_modules and package-lock.json
npm installBecause ncu can introduce breaking changes, review the diff and run your suite before committing. For more JS workflow tooling, see the TestMu AI roundup of must-have tools for JavaScript developers.
Updating dependencies in package.json is a two-tier job: use npm outdated and npm update for safe, in-range upgrades, and npm-check-updates when you deliberately want the latest majors. Understand the caret and tilde so you know what npm will and will not touch, always commit the updated lockfile, and upgrade in small, tested batches. Finish by running your test suite across real browsers so a routine update never turns into a production regression.
By design. npm update respects the semver ranges in package.json and only installs the highest wanted version within those ranges, so it never jumps to a new major version that could contain breaking changes. To move to a new major, change the range yourself or use npm-check-updates.
Wanted is the newest version allowed by the semver range in your package.json, which is what npm update installs. Latest is the newest version published to the registry regardless of your range. When Latest exceeds Wanted, a major upgrade is available that npm update will not apply automatically.
Install npm-check-updates, run ncu -u to rewrite every version range in package.json to the latest, then run npm install to apply them. This ignores existing semver constraints, so review the changes and run your test suite before committing.
The caret allows minor and patch updates but locks the major version, while the tilde allows only patch updates within a minor version. Both let npm pick newer compatible releases automatically while protecting you from breaking major changes.
Yes. The lockfile records the exact resolved versions of every dependency and transitive dependency, so committing it guarantees teammates and CI install the identical tree. Always commit an updated package-lock.json alongside package.json changes.
Run your automated test suite after every update, ideally across the browsers and devices your users have. Cross-browser test runs catch regressions that a single local environment misses, which is essential when a dependency upgrade changes rendering or behavior.
KaneAI - Testing Assistant
World’s first AI-Native E2E testing agent.

TestMu AI forEnterprise
Get access to solutions built on Enterprise
grade security, privacy, & compliance