Skip to content

feat: support partial Node version resolution - #81

Merged
1111mp merged 1 commit into
mainfrom
feat/support-version-range
Jul 28, 2026
Merged

feat: support partial Node version resolution#81
1111mp merged 1 commit into
mainfrom
feat/support-version-range

Conversation

@1111mp

@1111mp 1111mp commented Jul 28, 2026

Copy link
Copy Markdown
Owner

Overview

Close 1111mp/nvm-desktop#359

This PR adds Node version resolution support, allowing users to specify partial Node versions and automatically match the latest installed version.

Previously, nvmd only supported exact version matching:

nvmd use 14.21.3

With this change, users can specify a major or minor version:

nvmd use 14

and nvmd will automatically resolve it to the latest installed matching version.

Changes

  • Add NodeVersionResolver for Node version parsing and resolution
  • Support partial Node version matching:
    • 14 → latest installed 14.x.x
    • 14.18 → latest installed 14.18.x
    • 14.18.3 → exact version match
  • Support v prefix in version input:
    • v14
    • v14.18.3
  • Resolve user input to the actual installed Node version before switching
  • Improve version matching logic by selecting the highest available matching version

Examples

Assume the following Node versions are installed:

14.18.3
14.21.3
16.17.0
18.19.1

Major version matching

Command:

nvmd use 14

Resolved version:

14.21.3

Major and minor version matching

Command:

nvmd use 14.18

Resolved version:

14.18.3

Exact version matching

Command:

nvmd use 14.18.3

Resolved version:

14.18.3

Motivation

This change makes nvmd version selection more flexible and closer to the behavior of other Node version managers.

Users no longer need to remember or specify the exact patch version when switching Node versions. They can simply specify the major or minor version they need, and nvmd will select the latest installed compatible version automatically.

Implementation Details

  • Introduced NodeVersionRequest to represent different version requirements:
    • Exact version
    • Major version
    • Major/minor version
  • Added version resolution logic to:
    • Parse user input
    • Find installed Node versions
    • Select the latest matching version using semantic version comparison

Testing

Tested the following scenarios:

  • Exact version resolution
  • Major version resolution
  • Major/minor version resolution
  • v prefix version input
  • Multiple installed versions with the same major/minor version
  • Version matching with missing versions

@1111mp 1111mp changed the title feat: add node version resolver for version matching feat: support partial Node version resolution Jul 28, 2026
@1111mp
1111mp merged commit 214bd54 into main Jul 28, 2026
11 checks passed
@1111mp
1111mp deleted the feat/support-version-range branch July 28, 2026 07:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE]支持 .nvmrc / 项目版本文件按大版本匹配最新已安装 Node 版本

1 participant