Registry / serialization / node-semver

node-semver

JSON →
library0.9.1pypypi✓ verified 23d ago

A Python port of the popular `node-semver` library, which provides semantic versioning utilities as used by npm. The library helps in parsing, comparing, and ranging semantic versions (MAJOR.MINOR.PATCH) according to the SemVer 2.0.0 specification. The current stable version is 0.9.0, released on February 23, 2023. This library is maintained on an as-needed basis.

pip install node-semver
INSTALL
IMPORT
SIG · NODE-SEMVER
N
node-semver
serializationpythonv0.9.1
Install
1.5s avg
Import
72ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.9.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.074s · 17.9MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.5s · import 0.070s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

max_satisfying
from nodesemver import max_satisfying
from semver import max_satisfying
The module was renamed from `semver` to `nodesemver` in version 0.9.0 to avoid conflicts with `python-semver` and other libraries. Using `from semver import ...` will likely result in an `ImportError` or unexpected behavior if `python-semver` is also installed.

This quickstart demonstrates how to find the maximum version that satisfies a given semantic version range, with options for strict or loose matching and including pre-release versions.

from nodesemver import max_satisfying versions = ['1.2.3', '1.2.4', '1.2.5', '1.2.6', '2.0.1'] range_ = '~1.2.3' satisfying_version = max_satisfying(versions, range_, loose=False) print(f"Max satisfying version for range '{range_}' is: {satisfying_version}") # Expected: Max satisfying version for range '~1.2.3' is: 1.2.6 versions_with_prerelease = ['1.2.3', '1.2.4', '1.2.5', '1.2.6-pre.1', '2.0.1'] range_prerelease = '~1.2.3' satisfying_with_prerelease = max_satisfying(versions_with_prerelease, range_prerelease, loose=False, include_prerelease=True) print(f"Max satisfying (incl. prerelease) for range '{range_prerelease}' is: {satisfying_with_prerelease}") # Expected: Max satisfying (incl. prerelease) for range '~1.2.3' is: 1.2.6-pre.1
Debug
Known issues
breakingThe primary import module name changed from `semver` to `nodesemver` in version 0.9.0. Code using `from semver import ...` will fail with an `ImportError`.
fix
Update import statements to `from nodesemver import ...`.
affects: 0.9.0 and later
gotchaThis library might conflict with the `python-semver` package if both are installed and older `semver` import statements are still in use, leading to ambiguous imports.
fix
Ensure only one semantic versioning library is actively used, and update imports to `nodesemver` for this library. Consider uninstalling `python-semver` if not explicitly needed alongside `node-semver`.
affects: All versions, especially 0.9.0 onwards when migrating
gotchaWhen `loose=False`, parsing a version with a malformed pre-release (e.g., `2.0.0b1`) that doesn't strictly adhere to SemVer 2.0.0 rules can raise a `ValueError`, which may be unexpected if familiar with more permissive parsers.
fix
Catch `ValueError` when parsing potentially non-strict versions or set `loose=True` if more permissive parsing is desired.
affects: All versions
gotchaDespite a significant breaking change (module rename), the library's version number only incremented to 0.9.0, not 1.0.0, which might lead users to believe it's a minor change when it requires code modification.
fix
Always review release notes or `CHANGELOG.md` for any version update, especially when dealing with pre-1.0.0 releases where API stability guarantees are typically weaker.
affects: 0.9.0
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'semver'
This error typically occurs when the `node-semver` library (prior to version 0.9.0) or another `semver` library is installed, but a conflicting `semver` package is expected, or when `node-semver` version 0.9.0 or newer is installed and the code still tries to import from `semver` instead of `nodesemver`.
fix
If you intend to use `node-semver` (version 0.9.0 or newer), update your imports from `from semver import ...` to `from nodesemver import ...`. If you intended to use the `python-semver` library (pypi.org/project/semver), ensure `node-semver` is uninstalled or upgrade `node-semver` to 0.9.0+ to prevent the module name clash. Consider using separate virtual environments if both libraries are needed in their pre-0.9.0 conflicting states.
AttributeError: module 'semver' has no attribute 'parse_version_info'
This `AttributeError` commonly happens when the `node-semver` package is installed and clobbers the `semver` namespace intended for the `python-semver` library, leading to the wrong `semver` module being loaded. The `node-semver` module (before 0.9.0) does not expose a `parse_version_info` function.
fix
Upgrade `node-semver` to version 0.9.0 or later to resolve the module name clash, and then update your imports to use `nodesemver`. Alternatively, uninstall `node-semver` if you specifically need the `python-semver` library and its `parse_version_info` function.
ValueError: Invalid Version: ~1.2.3
This error occurs when you pass a version range string (e.g., using `~` or `^`) to a `node-semver` function that expects a strict semantic version string (e.g., '1.2.3') for parsing or validation, rather than a range specification. Range operators are not considered part of a 'valid version' itself in strict SemVer.
fix
When using functions like `semver.valid()` or `semver.parse()`, provide a strict semantic version string (e.g., '1.2.3'). For evaluating against ranges, use appropriate functions like `semver.satisfies(version, range_expression)` or `semver.max_satisfying(versions, range_expression)`.
Upgrade
Version history
0.9.1latest on PyPI · released Jun 23, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
5 hits · last 30 days
node
4
Resources
node-semver — pip install node-semver · libregistry