Updating Packages Safely
Complete guide to updating dependencies with npm update, pnpm update, handling major version breaking changes, and using interactive update CLI tools.
Keeping project dependencies updated ensures you receive the latest bug fixes, security patches, and performance optimizations.
Minor & Patch Updates (npm update)
The npm update command updates all packages to the highest version permitted by the SemVer constraints in your package.json (e.g. within ^ or ~ ranges):
# Update all packages within allowed semver ranges
npm update
# Update a specific package
npm update expressMajor Upgrades (Breaking Changes)
Because ^ prevents jumping to a new MAJOR version (e.g. from react@18 to react@19), npm update will not upgrade major versions.
Method 1: Explicit npm install
npm install express@latestMethod 2: Using npm-check-updates (NCU)
npm-check-updates analyzes package.json and upgrades version strings to the latest releases:
# Check available upgrades
npx npm-check-updates
# Upgrade package.json automatically
npx npm-check-updates -u
# Install the newly upgraded dependencies
npm installMethod 3: pnpm Interactive Updater (Built-In)
pnpm features a powerful interactive terminal updater:
# Interactively select packages with keyboard arrows and spacebar
pnpm update -i --latestPost-Update Verification Workflow
After updating dependencies:
- Run test suites:
npm test - Run TypeScript typecheck:
npm run typecheckornpx tsc --noEmit - Run linter:
npm run lint - Verify production build:
npm run build
Related Guides
Removing Packages (`npm uninstall` / `pnpm remove`)
Guide to uninstalling dependencies from package.json and node_modules, cleaning orphaned transitive packages, and removing global packages.
Checking Outdated Dependencies (`npm outdated`)
Complete guide to analyzing outdated dependencies with npm outdated and pnpm outdated, interpreting Current, Wanted, and Latest columns, and automation.