Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 5 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@ node -v
`vfox search nodejs` lists every release, with the npm that comes with it and a
mark on the ones of an LTS line. In an interactive terminal it lets you pick one.

Behavior that only exists on `main` and not in the latest release is marked
"Unreleased" in the pages below. [docs/changes.md](docs/changes.md) lists it, and
[docs/source-build.md](docs/source-build.md) gets you `main`.

### Example: Ubuntu 26.04

```bash
Expand Down Expand Up @@ -123,13 +119,11 @@ details and for mirrors that were checked.

vfox reads these files at every prompt in a directory that has one, and selects
the release they name if it is installed, so a `cd` into the directory switches.
Unreleased: release 0.5.3 reads them when a shell starts in the directory, not
after a `cd` from a running shell. Neither switches back when you `cd` into a
directory with no config at all; a `.vfox.toml`, which `vfox use --project`
writes, does. What a file can say depends on vfox's
`legacyVersionFile.strategy`: with the default, `specified`, only a full release
number selects something. A file in UTF-16 or with a byte order mark, which
Windows PowerShell 5.1 writes, is read too (Unreleased). See
It does not switch back when you `cd` into a directory with no config at all; a
`.vfox.toml`, which `vfox use --project` writes, does. What a file can say
depends on vfox's `legacyVersionFile.strategy`: with the default, `specified`,
only a full release number selects something. A file in UTF-16 or with a byte
order mark, which Windows PowerShell 5.1 writes, is read too. See
[docs/nvmrc.md](docs/nvmrc.md) for details.

## LTS
Expand Down
4 changes: 1 addition & 3 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ node -v

`vfox search nodejs` 会列出每个版本及其自带的 npm,属于 LTS 版本线的版本带有标记。在交互式终端里可以从中选一个。

只存在于 `main`、还没进入最新发布版的行为,在下面各页里标有“未发布”。[docs/zh-CN/changes.md](docs/zh-CN/changes.md) 里列出了这些行为,想直接用上 `main`,见 [docs/zh-CN/source-build.md](docs/zh-CN/source-build.md)。

### 示例:Ubuntu 26.04

```bash
Expand Down Expand Up @@ -80,7 +78,7 @@ Node.js 为 Linux(x64、arm64、ppc64le、s390x)、macOS(x64 和 arm64)

## `.nvmrc` 和 `.node-version`

每个提示符出现在带有这些文件的目录里时,vfox 都会读取它们,并选中其中指定的版本(前提是已经安装),所以 `cd` 进这个目录就会切换。未发布:0.5.3 在 Shell 于该目录里启动时读取,已经在运行的 Shell 里 `cd` 进来则不读取。两者在 `cd` 到完全没有配置的目录时都不会切换回来;`vfox use --project` 写出的 `.vfox.toml` 则会。文件里能写什么取决于 vfox 的 `legacyVersionFile.strategy`:默认值 `specified` 下,只有完整的版本号才能选中某个版本。UTF-16 的文件或带字节顺序标记的文件(Windows PowerShell 5.1 会写出这样的文件)也能读取(未发布)。详见 [docs/zh-CN/nvmrc.md](docs/zh-CN/nvmrc.md)。
每个提示符出现在带有这些文件的目录里时,vfox 都会读取它们,并选中其中指定的版本(前提是已经安装),所以 `cd` 进这个目录就会切换。`cd` 到完全没有配置的目录时不会切换回来;`vfox use --project` 写出的 `.vfox.toml` 则会。文件里能写什么取决于 vfox 的 `legacyVersionFile.strategy`:默认值 `specified` 下,只有完整的版本号才能选中某个版本。UTF-16 的文件或带字节顺序标记的文件(Windows PowerShell 5.1 会写出这样的文件)也能读取。详见 [docs/zh-CN/nvmrc.md](docs/zh-CN/nvmrc.md)。

## LTS

Expand Down
28 changes: 16 additions & 12 deletions docs/changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,27 @@

What changed in each release, as a user notices it. GitHub's
[release pages](https://github.com/version-fox/vfox-nodejs/releases) list the
pull requests. The newest release at the time of writing is 0.5.3, and `main` is
ahead of it by everything under "Unreleased".
[source-build.md](source-build.md) gets you those changes now.
pull requests.

## Unreleased
## 0.5.4 (2026-11-04)

- `vfox install nodejs@latest` installs the newest release again, and
`vfox search nodejs` no longer lists pre-releases. Since 2026-10-29 the index
of nodejs.org has `27.0.0-alpha.0.0.0` as its newest entry. Release 0.5.3
lists it first, so `latest` resolves to it and the install ends with
`version not found for provided version 27.0.0-alpha.0.0.0`. `nodejs@26` and
the other numbers work. Only releases of three numbers are listed now. See
[versions.md](versions.md#installing).
[versions.md](versions.md#installing)
([#43](https://github.com/version-fox/vfox-nodejs/pull/43)).
- Huawei Cloud, TUNA, USTC and BFSU work as mirrors. Release 0.5.3 leaves the
download of the package to vfox, which asks with the `User-Agent` of Go's HTTP
client, and these four answer that with an error page, or with nothing, in
place of the file (HTTP 418, 403, 204 and 403): the install ends in `checksum
error`. The plugin now has vfox download with the `User-Agent` of its own
requests, `vfox/1.0.13 vfox-nodejs/0.5.3` under vfox 1.0.13, and all of the
requests, `vfox/1.0.13 vfox-nodejs/0.5.4` under vfox 1.0.13, and all of the
mirrors of [mirror.md](mirror.md#mirrors-that-work) install 24.21.0. China
Telecom Cloud, `https://mirrors.ctyun.cn/nodejs-release`, is in that list now.
Telecom Cloud, `https://mirrors.ctyun.cn/nodejs-release`, is in that list now
([#45](https://github.com/version-fox/vfox-nodejs/pull/45)).
- The plugin learns the LTS lines from the version index, so a line that
Node.js promotes later needs no release of the plugin. It keeps what it
learned in `.lts-cache` next to the plugin. It writes the file when
Expand All @@ -36,27 +36,31 @@ ahead of it by everything under "Unreleased".
ends at Lithium (26): Node.js 26 entered long-term support on 2026-10-28.
Release 0.5.3 has the table only, and it ends at Krypton (24), so there
`lts/lithium` selects nothing under `latest_installed`, and `lts` and `lts/*`
select a 24.x. See [lts.md](lts.md#what-this-plugin-understands).
select a 24.x. See [lts.md](lts.md#what-this-plugin-understands)
([#44](https://github.com/version-fox/vfox-nodejs/pull/44)).
- A `.nvmrc` or `.node-version` in UTF-16, or in UTF-8 with a byte order mark,
is read. Windows PowerShell 5.1 writes the first with `>` and `Out-File`, and
the second with `-Encoding UTF8`. Release 0.5.3 reads the bytes as they are,
so no release matches the text and vfox says nothing. See
[nvmrc.md](nvmrc.md#what-the-file-may-hold).
[nvmrc.md](nvmrc.md#what-the-file-may-hold)
([#44](https://github.com/version-fox/vfox-nodejs/pull/44)).
- `.nvmrc` and `.node-version` are read at every prompt in their directory, so a
`cd` into it switches, and a change of the file takes effect at the next
prompt. Release 0.5.3 reads them when a shell starts in the directory and not
after a `cd`, because vfox 1.0.13 keeps the first result it worked out for the
shell and does not track version files. The plugin now removes that result
whenever vfox asks it to read such a file. A `cd` out of the directory into
one with no config at all does not switch back yet, and a `.vfox.toml` always
did. See [nvmrc.md](nvmrc.md#when-the-file-is-read). The cache is vfox's, and
vfox has been asked to fix it
did. See [nvmrc.md](nvmrc.md#when-the-file-is-read)
([#44](https://github.com/version-fox/vfox-nodejs/pull/44)). The cache is
vfox's, and vfox has been asked to fix it
([version-fox/vfox#745](https://github.com/version-fox/vfox/issues/745),
tracked here as [#46](https://github.com/version-fox/vfox-nodejs/issues/46)).
- The documentation has a page of scenarios: the nvm-sh/nvm commands next to
vfox's, Windows PowerShell 5.1 from scratch, one Node.js for a whole team,
several projects in one shell, `vfox exec`, mirrors and editors. See
[scenarios.md](scenarios.md).
[scenarios.md](scenarios.md)
([#44](https://github.com/version-fox/vfox-nodejs/pull/44)).

## 0.5.3 (2026-10-20)

Expand Down
14 changes: 4 additions & 10 deletions docs/lts.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ maintainer has to keep up:
answer for a while, so not every search does), and when it installs a release
and the file is missing or a day old. It keeps what it learned in `.lts-cache`
next to the plugin, where vfox keeps its `.available.cache`. Delete the file
to make it forget, and it learns again at the next install.
to make it forget, and it learns again at the next install. How it works is in
[development.md](development.md#what-the-plugin-learns-about-lts-lines).
- Before it has learned anything, or where it cannot write the file, it uses
the table below. The table is a start: a line that is missing from it is
learned as soon as the plugin has had the index in hand.
Expand Down Expand Up @@ -81,7 +82,7 @@ practice:

- Under `latest_available` the plugin finds the new codename in the index the
day it appears. `lts` and `lts/*` then name the newest release of the new
line, and `lts/lithium` worked there at once, with release 0.5.3 as well.
line, and `lts/lithium` worked there at once.
- Under `specified` and `latest_installed` the plugin knows the line from the
first time it has the index in hand after the promotion: the `vfox search` or
the install that brings you the new line. `latest_installed` selects nothing
Expand All @@ -90,13 +91,6 @@ practice:
line that the plugin knows.
- `(LTS)` in `vfox search` follows the index, so it changes at once.

Unreleased: release 0.5.3 has the table only, and no file. The table was
published before Lithium and ends at Krypton, so with 22.23.4, 24.22.2 and
26.13.0 installed on 2026-11-03 it selected 24.22.2 for `lts/*` and nothing for
`lts/lithium` under `latest_installed`, and only a release of the plugin adds a
line there. How the plugin learns is in
[development.md](development.md#what-the-plugin-learns-about-lts-lines).

## Examples

Given an `.nvmrc` (the same applies to `.node-version`) and
Expand All @@ -115,7 +109,7 @@ v22.23.4

```sh
# 2. Bare `lts` (or `lts/*`) means "the newest LTS line that the plugin knows",
# 26 at the time of writing (Unreleased: 24 in release 0.5.3).
# 26 at the time of writing.
$ printf 'lts\n' > .nvmrc
$ cd <dir-with-.nvmrc> && eval "$(vfox activate bash)" && eval "$(vfox env -s bash)" && node --version
v26.13.0
Expand Down
15 changes: 7 additions & 8 deletions docs/mirror.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,14 @@ A mirror can change or go away without the plugin knowing.

On 2026-11-03 each of them was also used to install 24.21.0 with vfox 1.0.13
(`VFOX_NODEJS_MIRROR=<mirror> vfox install nodejs@24.21.0`), and every one
installed it and ran. Unreleased: release 0.5.3 only installs from npmmirror,
Alibaba Cloud, Tencent Cloud and Nanjing University. It leaves the download to
vfox, which asks with the `User-Agent` of Go's HTTP client,
`Go-http-client/1.1`, and Huawei Cloud (HTTP 418), TUNA and BFSU (403) and USTC
(204 with no content) answer that with an error page, or with nothing, in place
of the package: vfox saves the answer and the install ends in `checksum error`.
installed it and ran. Before 0.5.4 the install through Huawei Cloud, TUNA, USTC
and BFSU ended in `checksum error`: vfox downloads the package itself, asking
with the `User-Agent` of Go's HTTP client, `Go-http-client/1.1`, and Huawei
Cloud (HTTP 418), TUNA and BFSU (403) and USTC (204 with no content) answer that
with an error page, or with nothing, in place of the package, which vfox saves.
The plugin asks for `index.json` and `SHASUMS256.txt` with the `User-Agent`
that vfox builds for it, `vfox/1.0.13 vfox-nodejs/0.5.3`, which all of them
serve, and it now has the download send the same one.
that vfox builds for it, `vfox/1.0.13 vfox-nodejs/0.5.4`, which all of them
serve, and it has the download send the same one.

Addresses that only redirect are not listed: on 2026-11-03
`mirror.sjtu.edu.cn/nodejs-release` sent the requests to nodejs.org, and
Expand Down
80 changes: 32 additions & 48 deletions docs/nvmrc.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ node -v # v22.23.3

vfox's shell hook reads the file at every prompt in the directory and selects
the release it names, so a `cd` into the directory switches, and so does a
change of the file. `vfox use` is not needed. Unreleased: release 0.5.3 reads
the file when a shell starts in the directory, not after a `cd` from a running
shell, where the example prints the global release. See
[below](#when-the-file-is-read). The hook is vfox's own, see its
change of the file. `vfox use` is not needed. The hook is vfox's own, see its
[quick start](https://vfox.dev/guides/quick-start.html) for zsh, fish,
PowerShell and the others.

Expand Down Expand Up @@ -59,43 +56,38 @@ when the `.vfox.toml` of the current directory is another one than before, when
1.0.13, and `main` of vfox on 2026-11-03), so vfox does not notice that the
shell is in a directory that has one.

Unreleased: the plugin makes up for that. vfox runs the plugin's
`ParseLegacyFile` before it looks at the kept result, and the plugin removes
`env-state.json` there (`util.forget_env_state`), so vfox works the environment
out again at every prompt in a directory with such a file. A `cd` into the
directory switches, a `cd` from one such directory to another does, and a
change of the file does at the next prompt. The extra calculation took about a
millisecond per prompt with one SDK installed, and `--debug` shows it as
`Config changed: true`. It is a workaround for vfox, to drop when vfox tracks
these files.
The plugin makes up for that. vfox runs the plugin's `ParseLegacyFile` before it
looks at the kept result, and the plugin removes `env-state.json` there
(`util.forget_env_state`), so vfox works the environment out again at every
prompt in a directory with such a file. A `cd` into the directory switches, a
`cd` from one such directory to another does, and a change of the file does at
the next prompt. The extra calculation took about a millisecond per prompt with
one SDK installed, and `--debug` shows it as `Config changed: true`. It is a
workaround for vfox, to drop when vfox tracks these files.

It does nothing for a `cd` out of the directory into one that has no config at
all. The plugin is not called there, so vfox goes on with the result it made for
the directory you left (`Using cached output`), and the shell keeps that
release. A directory with a `.vfox.toml` or with a version file of its own does
switch, and so does a new shell.

Release 0.5.3 does not remove the file. It reads a `.nvmrc` when the shell
starts in the directory, and again after a `vfox use`, and not after a `cd`,
in either direction. This is what `node -v` printed in one shell, step by step,
with vfox 1.0.13 and 26.13.0 as the global release (bash 5.3, and PowerShell
7.6.9 agrees):

| Step | Release 0.5.3 | Unreleased |
| --- | --- | --- |
| A shell that starts in a directory with a `.nvmrc` that names 18.20.8 | v18.20.8 | v18.20.8 |
| A shell that starts in a directory with no config at all | v26.13.0 | v26.13.0 |
| `cd` into the directory with the `.nvmrc` for 18.20.8 | v26.13.0 | v18.20.8 |
| `cd` into a directory with a `.node-version` that names 24.22.2 | v26.13.0 | v24.22.2 |
| Edit that `.node-version` to name 22.23.4 | v26.13.0 | v22.23.4 |
| `cd` into a directory with no config at all | v26.13.0 | v22.23.4 |
| `cd` into a directory with a `.vfox.toml` that names 18.20.8 | v18.20.8 | v18.20.8 |
| `cd` into a directory with no config at all | v26.13.0 | v26.13.0 |
This is what `node -v` printed in one shell, step by step, with vfox 1.0.13 and
26.13.0 as the global release (bash 5.3, and PowerShell 7.6.9 agrees):

| Step | `node -v` |
| --- | --- |
| A shell that starts in a directory with a `.nvmrc` that names 18.20.8 | v18.20.8 |
| A shell that starts in a directory with no config at all | v26.13.0 |
| `cd` into the directory with the `.nvmrc` for 18.20.8 | v18.20.8 |
| `cd` into a directory with a `.node-version` that names 24.22.2 | v24.22.2 |
| Edit that `.node-version` to name 22.23.4 | v22.23.4 |
| `cd` into a directory with no config at all | v22.23.4 |
| `cd` into a directory with a `.vfox.toml` that names 18.20.8 | v18.20.8 |
| `cd` into a directory with no config at all | v26.13.0 |

The first row is a shell of its own, the other seven follow one another in a
second shell. `vfox --debug env -s bash` shows both sides of the unreleased
column. In a directory with a `.nvmrc`, the plugin parses the file and vfox
calculates:
second shell. `vfox --debug env -s bash` shows both cases. In a directory with a
`.nvmrc`, the plugin parses the file and vfox calculates:

```text
Parsing legacy file /home/me/projects/legacy-api/.nvmrc
Expand All @@ -113,10 +105,9 @@ Config changed: false, configPaths: map[global:/home/me/.vfox/.vfox.toml]
Using cached output
```

Release 0.5.3 prints the second block in the directory with the `.nvmrc` as
well, after `Found nodejs@18.20.8`. A `.vfox.toml` is tracked in both, so
`vfox use --project nodejs@18.20.8` is the way to get the switching in a
release. See [scenarios.md](scenarios.md#several-projects-in-one-shell).
A `.vfox.toml` is tracked by vfox itself, so it switches in both directions:
`vfox use --project nodejs@18.20.8` writes one. See
[scenarios.md](scenarios.md#several-projects-in-one-shell).

The cache is vfox's, and so is the fix. It is reported as
[version-fox/vfox#745](https://github.com/version-fox/vfox/issues/745), and
Expand Down Expand Up @@ -158,9 +149,6 @@ Decoding means that a file in UTF-16, or in UTF-8 with a byte order mark, reads
like plain text. Windows PowerShell 5.1 writes such files with `>`, `Out-File`
and `-Encoding UTF8`, see
[scenarios.md](scenarios.md#writing-the-file-from-windows-powershell-51).
Unreleased: release 0.5.3 reads the bytes as they are, so the mark or the zero
bytes of UTF-16 become part of the text, no release matches it, and vfox says
nothing.

The results on 2026-11-03 with 20.20.2, 22.23.4, 24.21.0, 25.9.0 and 26.13.0
installed, when 24.22.2 is the newest 24.x and 22.23.4 the newest 22.x:
Expand All @@ -184,10 +172,7 @@ index names a newer release than the one you have, nothing is selected. Use
`latest_installed` that is the newest line that the plugin knows (26 at the time
of writing), under `latest_available` the newest release that carries any
codename in the index. See [lts.md](lts.md) for how the plugin knows lines and
what happens when Node.js promotes a new one. Unreleased: release 0.5.3 knows
only a table that ends at Krypton (24), because it was published before Node.js
26 became an LTS line. There `lts/lithium` selects nothing under
`latest_installed`, and `lts/*` and `lts` select 24.21.0 in the table above.
what happens when Node.js promotes a new one.

## Not understood

Expand Down Expand Up @@ -224,10 +209,9 @@ If the release does not switch:

- The shell hook is not active. `eval "$(vfox activate bash)"` has to run in
the shell, not only once somewhere else.
- Release 0.5.3 only: the shell was already running when you `cd`'d into the
directory, see [When the file is read](#when-the-file-is-read). Open a new
terminal there, or install the plugin of `main`
([source-build.md](source-build.md)).
- Before 0.5.4 only: the shell was already running when you `cd`'d into the
directory, and vfox went on with the release it had worked out for the shell.
Open a new terminal there, or update the plugin with `vfox update nodejs`.
- The shell came from a directory with a version file and went into one with no
config at all, and it keeps the release of the directory it left. Open a new
terminal.
Expand All @@ -238,7 +222,7 @@ If the release does not switch:
- A `.vfox.toml` or `.tool-versions` is in the way, or `legacyVersionFile.enable`
is `false`.
- The text is on the list above, or has a comment in it, or the file is in an
encoding the plugin does not read (release 0.5.3: anything but plain ASCII
encoding the plugin does not read (before 0.5.4: anything but plain ASCII
text).

`vfox --debug env -s bash` prints what the plugin returned and what vfox did
Expand Down
Loading
Loading