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
8 changes: 8 additions & 0 deletions docs/changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ ahead of it by everything under "Unreleased".
`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).
- 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
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.

## 0.5.3 (2026-10-20)

Expand Down
24 changes: 17 additions & 7 deletions docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ hooks/post_install.lua musl: fail when node cannot run, such as without
hooks/env_keys.lua PATH: bin on Linux and macOS, the install directory on Windows
hooks/pre_use.lua vfox use: map 24 or 24.21 to an installed release, note a shadowing node
hooks/parse_legacy_file.lua .nvmrc and .node-version
lib/util.lua mirror URL, musl detection and missing libraries, running a command, version comparison and matching, shorthands, PATH probe
lib/util.lua mirror URL and download headers, musl detection and missing libraries, running a command, version comparison and matching, shorthands, PATH probe
tests/hooks_test.lua offline hook tests
tests/e2e/ container tests, see e2e.md
Injection.lua type hints for what vfox injects, never loaded
Expand All @@ -39,12 +39,22 @@ loaded with `require("util")`.

A few contracts that cost time to find:

- `PreInstall` returns `version`, `url`, `sha256` and sometimes `note`.
`version` is the name of the install, so a start of a release has to be
resolved to the full release here. vfox only warns when there is no checksum
(`Checksum is not provided`) and goes on to download, so since 0.5.0 the hook
fails when the package is not in `SHASUMS256.txt` instead of returning none.
Notes that the hook prints with `print` show up in vfox's output.
- `PreInstall` returns `version`, `url`, `sha256`, `headers` and sometimes
`note`. `version` is the name of the install, so a start of a release has to
be resolved to the full release here. vfox only warns when there is no
checksum (`Checksum is not provided`) and goes on to download, so since 0.5.0
the hook fails when the package is not in `SHASUMS256.txt` instead of
returning none. Notes that the hook prints with `print` show up in vfox's
output.
- `headers` is what vfox sends with the download of `url`, which vfox makes, not
the plugin. Left out, vfox asks with the `User-Agent` of Go's HTTP client,
`Go-http-client/1.1`, and Huawei Cloud, TUNA, USTC and BFSU answer that with
an error page that vfox saves as the package, so the install ends in
`checksum error`. `util.download_headers()` gives the `User-Agent` that vfox
builds for the plugin's own requests, `vfox/<RUNTIME.version>
vfox-nodejs/<PLUGIN.version>`, which all of them serve. vfox 1.0.13 sends it
with the download, as a local server that logged the requests showed. The
unofficial site gets it too.
- `Available` raises on a network error or a status other than 200. Since 0.5.0
it does not return an empty list, which vfox cached. The result is kept in the
global `available_result` for the life of the process, and the tests reset it.
Expand Down
31 changes: 28 additions & 3 deletions docs/mirror.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,23 @@ The same layout as `nodejs.org/dist`:
release it lists but does not carry fails at the download.
- The sums in the mirror's own `SHASUMS256.txt` are what the download is checked
against. A mirror whose files differ from its sums ends in `checksum error`.
- A mirror can list a release before it has all of its files. On 2026-11-03,
six days after Node.js 26.13.0, npmmirror and Huawei Cloud listed it and
carried its 34 packages, but had no `SHASUMS256.txt` for it, so
`vfox install nodejs@26.13.0` through either ended in `get checksum failed:
HTTP 404 from https://npmmirror.com/mirrors/node/v26.13.0/SHASUMS256.txt`.
The plugin asks one mirror, so point `VFOX_NODEJS_MIRROR` at another one from
the list below, or unset it for nodejs.org, until the first has caught up.
- Redirects are followed. `https://npmmirror.com/mirrors/node` answers
`index.json` with a redirect, and works.

## Mirrors that work

These were checked on 2026-10-21: each served an `index.json` with the same 872
releases as nodejs.org, the same SHA-256 sum for `node-v24.21.0-linux-x64.tar.gz`
and the package itself, and the musl package of 26.12.0. The list records that
and endorses nothing. A mirror can change or go away without the plugin knowing.
and the package itself, and the musl package of 26.12.0. China Telecom Cloud was
checked the same way on 2026-11-03. The list records that and endorses nothing.
A mirror can change or go away without the plugin knowing.

| Mirror | `VFOX_NODEJS_MIRROR` |
| --- | --- |
Expand All @@ -76,7 +84,24 @@ and endorses nothing. A mirror can change or go away without the plugin knowing.
| Alibaba Cloud | `https://mirrors.aliyun.com/nodejs-release` |
| Tencent Cloud | `https://mirrors.cloud.tencent.com/nodejs-release` |
| Nanjing University | `https://mirror.nju.edu.cn/nodejs-release` |
| Beijing Foreign Studies University | `https://mirrors.bfsu.edu.cn/nodejs-release` |
| Beijing Foreign Studies University | `https://mirrors.bfsu.edu.cn/nodejs-release` (redirects to TUNA) |
| China Telecom Cloud | `https://mirrors.ctyun.cn/nodejs-release` |

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`.
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.

Addresses that only redirect are not listed: on 2026-11-03
`mirror.sjtu.edu.cn/nodejs-release` sent the requests to nodejs.org, and
`mirrors.cernet.edu.cn/nodejs-release` to a server of USTC.

The Node.js mirror is not the npm registry. Packages that `npm install` fetches
come from the registry in your npm config, for example `npm config set registry
Expand Down
18 changes: 14 additions & 4 deletions docs/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,14 @@ nodejs.org has listed that pre-release as its newest entry since 2026-10-29.

The plugin could not read the `SHASUMS256.txt` of the release, and says why
after the colon. `HTTP 404 from <address>` means the server has no such file:
the release does not exist (`24.99.0`), or the mirror lacks it. A network error
(`Get "<address>": tls: failed to verify certificate: x509: certificate signed
by unknown authority`, `... connection refused`, `... EOF`) means the server
could not be reached: a mirror that is down, a proxy, a TLS problem. See
the release does not exist (`24.99.0`), or the mirror lacks it. A mirror can
lack the file of a release that it lists in its `index.json` and carries the
packages of: npmmirror and Huawei Cloud did for 26.13.0 on 2026-11-03. Point
`VFOX_NODEJS_MIRROR` at another mirror, see
[mirror.md](mirror.md#mirrors-that-work), or unset it for nodejs.org. A network
error (`Get "<address>": tls: failed to verify certificate: x509: certificate
signed by unknown authority`, `... connection refused`, `... EOF`) means the
server could not be reached: a mirror that is down, a proxy, a TLS problem. See
[Network](#network).

### `Node.js package node-v19.8.1-win-arm64.zip is not listed in https://nodejs.org/dist/v19.8.1/SHASUMS256.txt`
Expand Down Expand Up @@ -88,6 +92,12 @@ stops when they differ. It names the file it dropped: `Checksum error, file:
cut-off download and a mirror whose files differ from its `SHASUMS256.txt`.
Nothing is installed. Run it again, or try another [mirror](mirror.md).

Unreleased: release 0.5.3 also ends here through Huawei Cloud, TUNA, USTC and
BFSU. vfox downloads with the `User-Agent` of Go's HTTP client, which they
answer with an error page, or with nothing, in place of the package, and vfox
checks that answer against the sum. The plugin now has the download send the
`User-Agent` of its own requests, see [mirror.md](mirror.md#mirrors-that-work).

### `nodejs@24.99 is not installed`

`vfox use` and `vfox uninstall` only know what is installed. `vfox list nodejs`
Expand Down
1 change: 1 addition & 0 deletions docs/zh-CN/changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
## 未发布

- `vfox install nodejs@latest` 重新安装最新的版本,`vfox search nodejs` 也不再列出预发布版本。2026-10-29 起,nodejs.org 的索引里最新的一条是 `27.0.0-alpha.0.0.0`。0.5.3 把它排在最前面,所以 `latest` 解析成它,安装以 `version not found for provided version 27.0.0-alpha.0.0.0` 告终。`nodejs@26` 等按编号安装的写法不受影响。现在只列出由三段数字组成的版本。见 [versions.md](versions.md#安装)。
- 华为云、TUNA、USTC 和北外现在可以用作镜像。0.5.3 把安装包的下载交给 vfox,而 vfox 请求时使用 Go HTTP 客户端的 `User-Agent`,这四个镜像对它返回的是错误页面或者空内容,而不是文件(依次是 HTTP 418、403、204 和 403),安装以 `checksum error` 结束。插件现在让 vfox 下载时使用它自己请求时的 `User-Agent`(vfox 1.0.13 下是 `vfox/1.0.13 vfox-nodejs/0.5.3`),[mirror.md](mirror.md#可用的镜像) 里的所有镜像都能安装 24.21.0。天翼云 `https://mirrors.ctyun.cn/nodejs-release` 也加进了这份列表。

## 0.5.3(2026-10-20)

Expand Down
5 changes: 3 additions & 2 deletions docs/zh-CN/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ hooks/post_install.lua musl:node 无法运行时报错,比如缺少
hooks/env_keys.lua PATH:Linux 和 macOS 上是 bin,Windows 上是安装目录
hooks/pre_use.lua vfox use:把 24 或 24.21 映射到已安装的版本,vfox 的 node 被遮蔽时给出提示
hooks/parse_legacy_file.lua .nvmrc 和 .node-version
lib/util.lua 镜像 URL、musl 检测与缺失的库、运行命令、版本比较与匹配、简写、PATH 探测
lib/util.lua 镜像 URL 与下载请求头、musl 检测与缺失的库、运行命令、版本比较与匹配、简写、PATH 探测
tests/hooks_test.lua 离线的钩子测试
tests/e2e/ 容器测试,见 e2e.md
Injection.lua vfox 注入对象的类型提示,不会被加载
Expand All @@ -34,7 +34,8 @@ vfox 加载 `metadata.lua`,命令需要时调用相应的钩子,并向钩子

几条容易踩坑的约定:

- `PreInstall` 返回 `version`、`url`、`sha256`,有时还有 `note`。`version` 就是安装后的版本名,所以这里必须把版本前缀解析成完整的版本。没有校验和时 vfox 只会警告(`Checksum is not provided`),然后继续下载,所以从 0.5.0 起,包不在 `SHASUMS256.txt` 里时钩子会报错,而不是不返回校验和。钩子用 `print` 打印的 Note 会出现在 vfox 的输出里。
- `PreInstall` 返回 `version`、`url`、`sha256`、`headers`,有时还有 `note`。`version` 就是安装后的版本名,所以这里必须把版本前缀解析成完整的版本。没有校验和时 vfox 只会警告(`Checksum is not provided`),然后继续下载,所以从 0.5.0 起,包不在 `SHASUMS256.txt` 里时钩子会报错,而不是不返回校验和。钩子用 `print` 打印的 Note 会出现在 vfox 的输出里。
- `headers` 是 vfox 下载 `url` 时带上的请求头,下载由 vfox 发起,不是插件。不写的话,vfox 请求时使用 Go HTTP 客户端的 `User-Agent`,即 `Go-http-client/1.1`,华为云、TUNA、USTC 和北外对它返回的是错误页面,vfox 把它存成安装包,安装就以 `checksum error` 结束。`util.download_headers()` 给出 vfox 为插件自己的请求生成的 `User-Agent`,即 `vfox/<RUNTIME.version> vfox-nodejs/<PLUGIN.version>`,这些镜像都正常响应。vfox 1.0.13 下载时会带上它,这是用一个记录请求的本地服务器确认的。非官方站点也用它。
- `Available` 遇到网络错误或 200 以外的状态码时会抛出错误。从 0.5.0 起它不再返回空列表,那样的结果会被 vfox 缓存。结果在进程存活期间保存在全局变量 `available_result` 里,测试会把它重置。vfox 自己还会把搜索结果缓存 12 小时。
- 对于无法映射的输入,`PreUse` 返回 `{ version = nil }`,vfox 就回答 `is not installed`。它拿到的 `ctx.installedSdks` 是以版本为键的表,而不是数组,所以 `calculate_shorthand` 用 `pairs` 遍历。
- `ParseLegacyFile` 调用 `ctx.getInstalledVersions()` 时不带参数。vfox 1.x 把它绑定成普通的 Go 函数,会拒绝 `ctx:getInstalledVersions()` 多传的那个参数。策略由 `ctx.strategy` 给出。vfox 把已安装的版本按字符串降序传进来,所以 `22.9.0` 排在 `22.23.3` 前面。测试把它当作普通函数传入,并断言调用时没有带参数。
Expand Down
10 changes: 8 additions & 2 deletions docs/zh-CN/mirror.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,12 @@ $env:VFOX_NODEJS_MIRROR = "https://npmmirror.com/mirrors/node"

- `index.json` 决定了 `vfox search nodejs`、`nodejs@latest`、`nodejs@24` 和 `nodejs@24.21` 能看到哪些版本。更新滞后的镜像列出的版本更少;列出了却没有提供的版本,会在下载时失败。
- 下载的文件会与镜像自己的 `SHASUMS256.txt` 里的校验和比对。文件与校验和对不上的镜像,最终会报 `checksum error`。
- 镜像可能在文件还没有备齐时就列出了某个版本。2026-11-03,也就是 Node.js 26.13.0 发布六天之后,npmmirror 和华为云列出了它,也有它的 34 个包,却没有它的 `SHASUMS256.txt`,所以通过其中任何一个执行 `vfox install nodejs@26.13.0`,都会以 `get checksum failed: HTTP 404 from https://npmmirror.com/mirrors/node/v26.13.0/SHASUMS256.txt` 结束。插件只询问一个镜像,所以在第一个镜像追上之前,请把 `VFOX_NODEJS_MIRROR` 指向下面列表里的另一个镜像,或者取消设置,改用 nodejs.org。
- 会跟随重定向。`https://npmmirror.com/mirrors/node` 对 `index.json` 的请求回应的是重定向,也能正常使用。

## 可用的镜像

这些镜像在 2026-10-21 检查过:每个镜像提供的 `index.json` 都和 nodejs.org 一样列有 872 个版本,`node-v24.21.0-linux-x64.tar.gz` 的 SHA-256 校验和以及包本身都与 nodejs.org 一致,也都提供了 26.12.0 的 musl 包。这份列表只是记录检查结果,不为任何镜像背书。镜像随时可能变化或消失,插件无从得知。
这些镜像在 2026-10-21 检查过:每个镜像提供的 `index.json` 都和 nodejs.org 一样列有 872 个版本,`node-v24.21.0-linux-x64.tar.gz` 的 SHA-256 校验和以及包本身都与 nodejs.org 一致,也都提供了 26.12.0 的 musl 包。天翼云是 2026-11-03 用同样的方法检查的。这份列表只是记录检查结果,不为任何镜像背书。镜像随时可能变化或消失,插件无从得知。

| 镜像 | `VFOX_NODEJS_MIRROR` |
| --- | --- |
Expand All @@ -63,7 +64,12 @@ $env:VFOX_NODEJS_MIRROR = "https://npmmirror.com/mirrors/node"
| 阿里云 | `https://mirrors.aliyun.com/nodejs-release` |
| 腾讯云 | `https://mirrors.cloud.tencent.com/nodejs-release` |
| 南京大学 | `https://mirror.nju.edu.cn/nodejs-release` |
| 北京外国语大学 | `https://mirrors.bfsu.edu.cn/nodejs-release` |
| 北京外国语大学 | `https://mirrors.bfsu.edu.cn/nodejs-release`(会重定向到 TUNA) |
| 天翼云 | `https://mirrors.ctyun.cn/nodejs-release` |

2026-11-03,又用 vfox 1.0.13 通过它们各安装了一次 24.21.0(`VFOX_NODEJS_MIRROR=<mirror> vfox install nodejs@24.21.0`),每一个都安装成功并且能运行。未发布:0.5.3 只能从 npmmirror、阿里云、腾讯云和南京大学安装。它把下载交给 vfox,而 vfox 请求时使用的是 Go HTTP 客户端的 `User-Agent`,即 `Go-http-client/1.1`,华为云(HTTP 418)、TUNA 和北外(403)以及 USTC(204,没有内容)对它返回的是错误页面或者空内容,而不是安装包:vfox 把这个回应存成文件,安装以 `checksum error` 结束。插件请求 `index.json` 和 `SHASUMS256.txt` 时用的是 vfox 为它生成的 `User-Agent`,即 `vfox/1.0.13 vfox-nodejs/0.5.3`,这些镜像都正常响应,现在下载时也改用同一个。

只做重定向的地址没有列出:2026-11-03,`mirror.sjtu.edu.cn/nodejs-release` 把请求转到了 nodejs.org,`mirrors.cernet.edu.cn/nodejs-release` 则转到了中科大的一台服务器。

Node.js 的镜像不是 npm 的 registry。`npm install` 获取的包来自 npm 配置里的 registry,例如 `npm config set registry https://registry.npmmirror.com`,见 [npm.md](npm.md)。

Expand Down
4 changes: 3 additions & 1 deletion docs/zh-CN/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

### `get checksum failed: HTTP 404 from https://nodejs.org/dist/v24.99.0/SHASUMS256.txt`

插件读不到这个版本的 `SHASUMS256.txt`,原因写在冒号后面。`HTTP 404 from <address>` 表示服务器上没有这个文件:要么这个版本不存在(`24.99.0`),要么镜像里没有它。网络错误(`Get "<address>": tls: failed to verify certificate: x509: certificate signed by unknown authority`、`... connection refused`、`... EOF`)表示连不上服务器:镜像不可用、代理有问题,或者 TLS 出了问题。见[网络](#网络)。
插件读不到这个版本的 `SHASUMS256.txt`,原因写在冒号后面。`HTTP 404 from <address>` 表示服务器上没有这个文件:要么这个版本不存在(`24.99.0`),要么镜像里没有它。镜像可能在 `index.json` 里列出了某个版本、也有它的包,却没有它的 `SHASUMS256.txt`:2026-11-03 的 npmmirror 和华为云对 26.13.0 就是这样。请把 `VFOX_NODEJS_MIRROR` 指向另一个镜像,见 [mirror.md](mirror.md#可用的镜像),或者取消设置,改用 nodejs.org。网络错误(`Get "<address>": tls: failed to verify certificate: x509: certificate signed by unknown authority`、`... connection refused`、`... EOF`)表示连不上服务器:镜像不可用、代理有问题,或者 TLS 出了问题。见[网络](#网络)。

### `Node.js package node-v19.8.1-win-arm64.zip is not listed in https://nodejs.org/dist/v19.8.1/SHASUMS256.txt`

Expand Down Expand Up @@ -46,6 +46,8 @@ vfox 没有告诉插件当前运行在哪种 CPU 上。这是不应该出现的

vfox 会打印 `Verifying checksum <sum>...`,拿下载的文件和这个校验和比对,不一致就停下来,并指出它丢弃的文件:`Checksum error, file: ~/.vfox/cache/nodejs/node-v24.21.0-linux-x64.tar.gz`。常见的原因是下载被截断,或者镜像上的文件与它自己的 `SHASUMS256.txt` 对不上。不会安装任何东西。请重试,或者换一个[镜像](mirror.md)。

未发布:0.5.3 通过华为云、TUNA、USTC 和北外安装时也会停在这里。vfox 下载时使用 Go HTTP 客户端的 `User-Agent`,这几个镜像对它返回的是错误页面或者空内容,而不是安装包,vfox 再拿这个回应去比对校验和。插件现在让下载使用它自己请求时的 `User-Agent`,见 [mirror.md](mirror.md#可用的镜像)。

### `nodejs@24.99 is not installed`

`vfox use` 和 `vfox uninstall` 只认已安装的版本,`vfox list nodejs` 可以看到它们。对已安装的版本,`vfox use` 接受 `24`、`24.21` 和 `24.21.0`,`vfox uninstall` 需要写完整的版本号。见 [versions.md](versions.md#使用)。
Expand Down
Loading
Loading