Skip to content

fix(nodeenv): skip node.js pre-releases for latest and ranges - #454

Merged
ekalinin merged 1 commit into
masterfrom
fix/latest-skips-prereleases
Oct 29, 2026
Merged

ekalinin merged 1 commit into
masterfrom
fix/latest-skips-prereleases

Conversation

@ekalinin

Copy link
Copy Markdown
Owner

Fixes #453

What happens

Since 2026-10-29 the first entry of nodejs.org's index.json is v27.0.0-alpha.0.0.0. Two paths pick versions from that index, and both stop with ValueError: invalid literal for int() with base 10: '0-alpha' before anything is downloaded:

  • latest, the default: _get_last_node_version() takes the first entry with a build for the platform, so it returns the alpha, and parse_version() fails on it in create_environment().
  • semver ranges such as --node=26 or --node='*': resolve_node_version() runs parse_version() on every entry of the index, the alpha included. The issue does not mention this path.

Reproduced on master. The 1.11.0 release has the same code. It also fails the integration, git-bash and with-npm-windows CI jobs, which use the default version, on every pull request (seen on #431).

What changes

  • A new _is_prerelease() treats a version with a - as a pre-release. _get_last_node_version() and resolve_node_version() skip such entries, so latest and ranges resolve to stable releases only, as README and --help describe latest.
  • parse_version() drops a -... suffix of the patch part, as it already drops +.... An exact pre-release such as --node=27.0.0-alpha.0.0.0 installs instead of crashing.

The parse_version() change alone is not enough: resolve_node_version('*') then returns 27.0.0, which does not exist on nodejs.org.

Tests

The new tests fail on master and pass with the fix:

  • test_get_latest_node_version_skips_prerelease and test_resolve_node_version_skips_prerelease use the new mock_index_json_alpha fixture, which puts the real alpha entry from today's index.json in front of nodejs_index.json;
  • test_parse_version gets a case for v27.0.0-alpha.0.0.0.

The integration tests pass locally against the real nodejs.org (8 passed, 3 skipped: Windows only), and nodeenv --prebuilt -n 27.0.0-alpha.0.0.0 installs a node that reports v27.0.0-alpha.0.0.0.

nodejs.org now lists v27.0.0-alpha.0.0.0 first in index.json. latest
took the first entry with a build for the platform, and semver ranges
ran parse_version on every entry, so both stopped with a ValueError on
'0-alpha' before anything was downloaded.

Both now skip pre-releases, and parse_version drops a '-' suffix of the
patch part as it already drops '+', so an exact pre-release given with
--node installs.

Fixes #453
@ekalinin
ekalinin merged commit 8dee9f3 into master Oct 29, 2026
46 checks passed
ekalinin added a commit to jihtsan/nodeenv that referenced this pull request Oct 29, 2026
The integration, git-bash and with-npm-windows jobs failed on 6d6b79b
because master did not have the ekalinin#453 fix yet: latest resolved to
27.0.0-alpha.0.0.0 and crashed in parse_version. Master now has it
(ekalinin#454) and keeps the ekalinin#453 entry in its 1.11.1 section (ekalinin#455), so the
merge has no conflicts.
@ekalinin ekalinin added the bug label Oct 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

latest resolves to 27.0.0-alpha.0.0.0 and crashes in parse_version

1 participant