semver
The semantic version parser used by npm — parse, compare, and satisfy version ranges.
semver
General JSThe semantic version parser used by npm — parse, compare, and satisfy version ranges.
Fit
Bundle (gzip)
7.7 kB
25.0 kB raw
Install size includes transitive dependencies. Bundle size is gzipped browser payload.
Freshness
The Problem
Comparing version strings like 1.2.10 vs 1.2.9 with plain string or numeric comparisons is wrong, and checking whether a version satisfies a range such as ^1.4.0 by hand is tedious and bug-prone.
What It Does
semver implements the SemVer spec: it parses versions, compares them correctly, and tests them against ranges (^, ~, >=, etc.). It powers npm's own dependency resolution and is a foundational dependency across the ecosystem.
Installation
npm install semverUsage Example
import semver from "semver";
semver.gt("1.2.10", "1.2.9"); // true
semver.satisfies("1.4.2", "^1.4.0"); // true
semver.coerce("v2.3").version; // "2.3.0"
semver.inc("1.0.0", "minor"); // "1.1.0"Related packages
Unified TypeScript SDK for building AI-powered apps — switch between 20+ LLM providers without rewriting code.
animejsGeneral JSLightweight JavaScript animation library with a tiny footprint and a powerful, expressive API.
AOSGeneral JSAn easy-to-use library that makes elements fade, slide, or zoom into view as the user scrolls down your page.
archiverGeneral JSStreaming interface for generating ZIP and TAR archives in Node.js — create compressed archives programmatically from files, directories, and buffers.
@formkit/auto-animateGeneral JS> Add smooth transitions to any element with a single line — zero-config animations for adds, removes, and moves.