align-deps-vers
v1.0.2
Published
CLI tool to align package.json dependency versions with actually installed versions, i.e. ^6.0.0 to ^6.2.2
Maintainers
Readme
align-deps-vers
🛠️ A tiny CLI tool to align semver-declared dependency versions in
package.jsonwith what’s actually installed innode_modules.
What it does
When dependencies are declared like:
"chalk": "^5.0.0"But node_modules contains a newer compatible version, say:
"chalk": "5.3.0"This tool updates your package.json to:
"chalk": "^5.3.0"➡️ Keeping your semver prefixes (^, ~, etc.), while reflecting actual versions.
Usage
Run instantly with npx
npx align-deps-versThis:
- Reads your
package.json - Gets actual installed versions
- Rewrites all matching dependencies with updated (actual) versions
How It Works
- Calls
npm list --json - Resolves top-level installed packages from
node_modules - Walks through:
dependenciesdevDependenciesoptionalDependencies
- If the declared version uses a prefix (
^,~, etc.) — it replaces only the version part, not the prefix
Example
Before:
"dependencies": {
"chalk": "^5.0.0",
"ora": "~6.0.0"
}Actually installed:
After:
"dependencies": {
"chalk": "^5.3.0",
"ora": "~6.1.1"
}Use Case
Useful for:
- Committing package updates with accurate dependency metadata
- Snapshotting versions for auditability and long-term tracking
- Improving visibility into the actual versions installed in
node_modules(let's be honest, package-lock.json is not human-friendly) - Avoiding confusion caused by mismatches between declared and real versions
