maintaining-npm-packages
Installation
SKILL.md
NPM Package Maintenance
Gotchas
- Override target must be a FIXED version — The most common failure mode: adding
"vite": ">=7.3.2"topnpm.overrideslets pnpm silently install8.x.yon the next install, causing major-version cascading regressions. Override targets must be exact ("vite": "7.3.2"). See "Override Safety Rule" below for the real-incident reference from April 2026. The LEFT side of an override may carry a range (to select affected versions); the RIGHT side must be fixed. - An EXACT override target can still be vulnerable — exact is necessary but NOT sufficient: the target must also be
>=the advisory's fixed-in version. Pinninguuidto11.1.0(exact, same major) when the fix landed in11.1.1leaves the advisory open — the override silently "works" but resolves a still-vulnerable version. After EVERY override, re-runauditand confirm the targeted package is gone. If it still appears, the target is one patch too low or the selector mis-scoped — bump it; do NOT record it as "blocked" or "needs a framework update". npm auditandpnpm auditdisagree on the same dependencies — different package managers resolve transitive versions differently (pnpm floats to the newest in-range patched release; npm can keep an older locked one) and the override block lives in different places:overrides(npm),pnpm.overrides(pnpm),resolutions(yarn). A reference starter reporting "0 vulnerabilities" under pnpm does NOT mean an npm-based consumer is clean. Always audit with the PROJECT's own package manager, and target the patched versions the reference resolves to.pnpm audit --fix --forcecan cause major version jumps — Step 3 of the escalation ladder is destructive. It will happily upgrade a transitive dependency from^1.xto3.xif that closes the CVE. Always verifypnpm run buildand the full test suite after using it, and prefer a scoped override for transitives where a compatible patch exists.- Deprecated packages in
devDependenciesoften lag —@types/*packages in particular remain flagged as deprecated for months after the upstream merges types natively. Don't remove them blindly — check the affected imports still resolve via the new inline types before deleting. packageManagerfield locks pnpm/npm/yarn version — When running maintenance across a monorepo, thepackageManager: "pnpm@X.Y.Z"field in the rootpackage.jsonpins the exact version. Upgrading pnpm without also bumping this field causes CI and local runs to diverge silently.
When to Use This Skill
- User mentions outdated packages or wants to update dependencies
- Security vulnerabilities found via
pnpm audit - Need to optimize
dependenciesvsdevDependencies - Removing unused packages from
package.json - Pre-release or post-feature dependency cleanup
- General package maintenance or housekeeping tasks