diff --git a/docs/_components/VersionSpecifierTable.mdx b/docs/_components/VersionSpecifierTable.mdx index 43a6b53..4053afa 100644 --- a/docs/_components/VersionSpecifierTable.mdx +++ b/docs/_components/VersionSpecifierTable.mdx @@ -4,6 +4,7 @@ | Latest alpha | `alpha` | Newest release whose version contains `-alpha`. Keeps the full prerelease tag for download. | | Latest LTS | `lts` | Newest available LTS release. | | Named LTS line | `lts/iron` | Newest release from the named LTS line. | +| Previous LTS line(s) | `lts/-1`, `lts/-2` | Nth previous unique LTS line (newest first). Same meaning as unix `nvm`. | | User alias | `legacy` | Version assigned with [`nvm alias add`](../command/nvm/alias/add). | | Major only | `24` | Newest matching `24.x.x` release. | | Major.minor | `24.1` | Newest matching `24.1.x` release. | diff --git a/docs/cfg/aliases.md b/docs/cfg/aliases.md index 9f3b8fb..b0cae84 100644 --- a/docs/cfg/aliases.md +++ b/docs/cfg/aliases.md @@ -110,7 +110,7 @@ next -> v24.11.0 | `alpha` | Built-in: newest `-alpha*` catalog release | | `daily`, `beta`, `prerelease` | Reserved for future use | | `link`, `shim` | Operating mode names | -| `lts/*` (for example `lts/iron`) | Reserved LTS namespace | +| `lts/*` (for example `lts/iron`, `lts/-1`) | Reserved LTS namespace (codenames and `lts/-N` offsets are built-in) | Pick names like `legacy`, `apps`, `ci`, or `stable24` instead. diff --git a/docs/command/nvm/alias/index.md b/docs/command/nvm/alias/index.md index d195388..c2621c3 100644 --- a/docs/command/nvm/alias/index.md +++ b/docs/command/nvm/alias/index.md @@ -30,7 +30,7 @@ Usage: nvm alias | `default`, `current`, `latest`, `lts`, `last` | Built-in command semantics | | `daily`, `alpha`, `beta`, `prerelease` | Reserved for future use | | `link`, `shim` | Operating mode names | -| `lts/*` | Reserved LTS namespace (for example `lts/iron`) | +| `lts/*` | Reserved LTS namespace (for example `lts/iron`, `lts/-1`) | ## Notes diff --git a/docs/command/nvm/install/index.md b/docs/command/nvm/install/index.md index 6df4b36..23b2d48 100644 --- a/docs/command/nvm/install/index.md +++ b/docs/command/nvm/install/index.md @@ -53,6 +53,7 @@ nvm install alpha nvm install 24 nvm install 22.14.0 20.19.1 nvm install lts/iron +nvm install lts/-1 nvm install 24 --cache nvm install 24 --no-cache nvm install 24.0.0 --force diff --git a/docs/features/all-features.md b/docs/features/all-features.md index 700ee15..640d421 100644 --- a/docs/features/all-features.md +++ b/docs/features/all-features.md @@ -32,7 +32,7 @@ See [What's new in v2](./newv2) for a shorter v2 summary. | Feature | Description | |:-|:-| -| [Install](../command/nvm/install/) | Install one or more Node.js versions. Specs include `latest`, `lts`, `lts/`, and `x.x.x`. | +| [Install](../command/nvm/install/) | Install one or more Node.js versions. Specs include `latest`, `lts`, `lts/`, `lts/-N`, and `x.x.x`. | | Parallel installations | Each requested version installs in its own goroutine. | | Compact `.7z` archives | Downloads are Windows `.7z` archives (x64 or arm64). Size is about 40% smaller than the old layout. | | Native extraction | NVM uses installed 7-Zip when present. Otherwise it uses the embedded extractor. | diff --git a/docs/guide/version-resolution.md b/docs/guide/version-resolution.md index eddc010..b7a0af8 100644 --- a/docs/guide/version-resolution.md +++ b/docs/guide/version-resolution.md @@ -54,6 +54,10 @@ nvm install alpha # named LTS line nvm install lts/iron +# previous LTS lines (offset from current LTS) +nvm install lts/-1 +nvm use lts/-2 + # partial and exact versions nvm use 24.1 nvm cache add 22.14.0 @@ -63,6 +67,18 @@ nvm alias add stable 24.1.0 nvm use stable ``` +### LTS offsets (`lts/-N`) + +`lts/-N` selects the Nth previous LTS **line** relative to the current latest LTS (`lts`). Catalog order is newest first. Unique LTS codenames form the line list; `lts/-1` is the second line, `lts/-2` the third, and so on. `N` must be a positive integer (`lts/-0` is invalid). + +Any name under `lts/` that starts with `-` is offset syntax only. It is never treated as a codename. + +| Input | Result | +|-------|--------| +| `lts/-1` | Previous LTS line’s newest release | +| `lts/-0`, `lts/-`, `lts/-1x`, `lts/--1` | Error: invalid LTS offset (use `lts/-N` with a positive integer) | +| `lts/-99` when fewer lines exist | Error: LTS offset out of range | + ## Version constraints Version constraints describe acceptable releases in project pinning and @@ -97,7 +113,7 @@ Example: default `13.14.0`, `engines.node` is `>=20`. `13.14.0` does not satisfy ## Resolution order {/* #resolution-order */} 1. User alias mapping (from `nvm alias add`) -2. Reserved aliases (`latest`, `alpha`, `lts`, `lts/`) +2. Reserved aliases (`latest`, `alpha`, `lts`, `lts/`, `lts/-N`) 3. Partial versions expanded to the best matching concrete release 4. Semver constraints resolved in constraint-aware flows (for example `engines.node` or caret/tilde ranges in detect files) 5. Read version string from the configured detect file in the current directory tree (auto-detect)