From 534a24bcdbd9286ebd55b24b287d679b7f31bff5 Mon Sep 17 00:00:00 2001 From: Qiheng He Date: Tue, 3 Nov 2026 17:03:56 +0800 Subject: [PATCH 1/2] fix(pre_install): download with the User-Agent of vfox's own requests vfox downloads the package itself, and without `headers` in the result of PreInstall it asks with the User-Agent of Go's HTTP client, `Go-http-client/1.1`. Huawei Cloud, TUNA, USTC and BFSU answer that with an error page, or with nothing, in place of the file (HTTP 418, 403, 204 and 403, measured with curl on 2026-11-03). vfox saves the answer as the package and the install ends in `checksum error`. The plugin's own requests for index.json and SHASUMS256.txt carry the User-Agent that vfox builds for it, `vfox/1.0.13 vfox-nodejs/0.5.3`, which all of them serve, so the plugin saw nothing wrong. The mirror table in docs/mirror.md had been checked with curl, which sends a User-Agent of its own. PreInstall now returns `headers` with that same User-Agent, built by util.download_headers() from RUNTIME.version, PLUGIN.name and PLUGIN.version, and leaving out what vfox does not provide. Both results get it: the package of the mirror and the unofficial musl build. vfox 1.0.13 sends it: a local server that logged the requests saw `Go-http-client/1.1` on the download before, and `vfox/1.0.13 vfox-nodejs/0.5.3` after, as on the SHASUMS256.txt request. With vfox 1.0.13 on Linux amd64, in a sandbox with its own HOME and an empty environment, `VFOX_NODEJS_MIRROR= vfox install nodejs@24.21.0` installs and runs through npmmirror (and cdn.npmmirror.com), Huawei Cloud, TUNA, USTC, Alibaba Cloud, Tencent Cloud, Nanjing University, BFSU and China Telecom Cloud. Before the change Huawei Cloud, TUNA, USTC and BFSU ended in `checksum error`. The hook tests check `headers` on every platform case and on the unofficial build, and util.download_headers() with and without each of the three inputs. Six mutations of the code, such as no headers on one of the results or Go's User-Agent, each turned a test red. --- hooks/pre_install.lua | 2 ++ lib/util.lua | 20 ++++++++++++++++++++ tests/hooks_test.lua | 42 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+) diff --git a/hooks/pre_install.lua b/hooks/pre_install.lua index 1a620e8..043a167 100644 --- a/hooks/pre_install.lua +++ b/hooks/pre_install.lua @@ -114,6 +114,7 @@ function PLUGIN:PreInstall(ctx) version = version, url = baseUrl .. filename, sha256 = checksum, + headers = util.download_headers(), } if musl_note ~= nil then result.note = musl_note @@ -140,6 +141,7 @@ function PLUGIN:PreInstall(ctx) version = version, url = unofficialBase .. filename, sha256 = uchecksum, + headers = util.download_headers(), note = musl_note, } end diff --git a/lib/util.lua b/lib/util.lua index 7037f5d..6c3b30b 100644 --- a/lib/util.lua +++ b/lib/util.lua @@ -31,6 +31,26 @@ function UTIL.getBaseUrl() return (mirror:gsub("/+$", "")) end +--- Headers that vfox sends with the download of the package. Without them vfox +--- identifies itself 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, or with nothing, in place of the package: vfox saves the +--- answer and the install ends in `checksum error`. The requests of the plugin +--- itself carry the User-Agent that vfox builds for it, `vfox/ +--- vfox-nodejs/`, which all the mirrors of docs/mirror.md +--- serve, so the download sends the same. +--- @return table +function UTIL.download_headers() + local agent = "vfox-" .. ((PLUGIN ~= nil and PLUGIN.name) or "nodejs") + if PLUGIN ~= nil and PLUGIN.version ~= nil then + agent = agent .. "/" .. PLUGIN.version + end + if RUNTIME ~= nil and RUNTIME.version ~= nil and RUNTIME.version ~= "" then + agent = "vfox/" .. RUNTIME.version .. " " .. agent + end + return { ["User-Agent"] = agent } +end + function UTIL.file_exists(path) local f = io.open(path, "rb") if f then diff --git a/tests/hooks_test.lua b/tests/hooks_test.lua index 3ad4bae..5fde861 100644 --- a/tests/hooks_test.lua +++ b/tests/hooks_test.lua @@ -113,6 +113,9 @@ for _, case in ipairs(cases) do local result = PLUGIN:PreInstall({ version = "20.16.0" }) assert(result.url:sub(-#filename) == filename, result.url) assert(result.sha256 == hash, "checksum missing") + -- vfox downloads with what is in `headers`, or else with Go's User-Agent. + assert(result.headers ~= nil and result.headers["User-Agent"] ~= nil, "download without a User-Agent") + assert(not result.headers["User-Agent"]:find("Go-http-client", 1, true), result.headers["User-Agent"]) end) end test("missing architecture", function() @@ -159,6 +162,7 @@ test("package linux/arm64 musl falls back to unofficial", function() assert(result.url:sub(-#filename) == filename, result.url) assert(result.url:find("unofficial-builds.nodejs.org", 1, true), result.url) assert(result.sha256 == unofficial_hash, "unofficial checksum missing") + assert(result.headers ~= nil and result.headers["User-Agent"] ~= nil, "unofficial download without a User-Agent") end) test("musl unsupported architecture", function() RUNTIME = { osType = "linux", archType = "386", envType = "musl" } @@ -636,6 +640,44 @@ test("capture runs a command and returns what it printed", function() assert(output == "hi\n", tostring(output)) assert(status == 0 or status == nil, tostring(status)) end) +-- vfox downloads the package itself and, unless PreInstall says otherwise, with +-- Go's User-Agent, which Huawei Cloud, TUNA, USTC and BFSU answer with an error +-- page. The plugin's own requests carry `vfox/ vfox-nodejs/` +-- (seen on a local server under vfox 1.0.13), and the download sends the same. +local function with_identity(plugin_name, plugin_version, vfox_version, fn) + local saved_name, saved_version, saved_runtime = PLUGIN.name, PLUGIN.version, RUNTIME + PLUGIN.name, PLUGIN.version = plugin_name, plugin_version + RUNTIME = { osType = "linux", archType = "amd64", envType = "gnu", version = vfox_version } + local ok, err = pcall(fn) + PLUGIN.name, PLUGIN.version, RUNTIME = saved_name, saved_version, saved_runtime + assert(ok, err) +end +test("download_headers names vfox and the plugin like the plugin's own requests", function() + with_identity("nodejs", "0.5.3", "1.0.13", function() + assert(util.download_headers()["User-Agent"] == "vfox/1.0.13 vfox-nodejs/0.5.3") + end) + -- Whatever vfox leaves out is left out of the name too. + with_identity("nodejs", "0.5.3", nil, function() + assert(util.download_headers()["User-Agent"] == "vfox-nodejs/0.5.3") + end) + with_identity("nodejs", "0.5.3", "", function() + assert(util.download_headers()["User-Agent"] == "vfox-nodejs/0.5.3") + end) + with_identity("nodejs", nil, "1.0.13", function() + assert(util.download_headers()["User-Agent"] == "vfox/1.0.13 vfox-nodejs") + end) + with_identity(nil, nil, nil, function() + assert(util.download_headers()["User-Agent"] == "vfox-nodejs") + end) +end) +test("the package is downloaded with the User-Agent of vfox", function() + with_identity("nodejs", "0.5.3", "1.0.13", function() + local filename = "node-v20.16.0-linux-x64.tar.gz" + state.response = { status_code = 200, body = string.rep("a", 64) .. " " .. filename .. "\n" } + local result = PLUGIN:PreInstall({ version = "20.16.0" }) + assert(result.headers["User-Agent"] == "vfox/1.0.13 vfox-nodejs/0.5.3", result.headers["User-Agent"]) + end) +end) test("shell_quote quotes one word", function() assert(util.shell_quote("a b") == "'a b'") assert(util.shell_quote("it's") == "'it'\\''s'") From 90d9495383a2bac42734240786dad9cde6829f7d Mon Sep 17 00:00:00 2001 From: Qiheng He Date: Tue, 3 Nov 2026 17:03:56 +0800 Subject: [PATCH 2/2] docs(mirror): record which mirrors install with vfox, add China Telecom Cloud docs/mirror.md listed eight mirrors as working on the strength of a curl check. On 2026-11-03 they were tried with `vfox install nodejs@24.21.0` (vfox 1.0.13) as well, and with release 0.5.3 only npmmirror, Alibaba Cloud, Tencent Cloud and Nanjing University install. The page says so under an "Unreleased" remark, with the cause and what the plugin does about it. The table lists China Telecom Cloud (https://mirrors.ctyun.cn/nodejs-release), checked the way the others were, and marks BFSU as a redirect to TUNA. Addresses that only redirect are not listed: mirror.sjtu.edu.cn sent the requests to nodejs.org and mirrors.cernet.edu.cn to a server of USTC. The page also records the gap of 2026-11-03: npmmirror and Huawei Cloud listed 26.13.0 and carried its 34 packages, but had no SHASUMS256.txt for it, so the install ends in `get checksum failed: HTTP 404`. The plugin asks one mirror, so the advice is to point VFOX_NODEJS_MIRROR at another one, or to unset it. troubleshooting.md gets the same advice under that message and the new cause under `checksum error`, development.md the `headers` contract of PreInstall, and changes.md an "Unreleased" entry, each with its translation. --- docs/changes.md | 8 ++++++++ docs/development.md | 24 +++++++++++++++++------- docs/mirror.md | 31 ++++++++++++++++++++++++++++--- docs/troubleshooting.md | 18 ++++++++++++++---- docs/zh-CN/changes.md | 1 + docs/zh-CN/development.md | 5 +++-- docs/zh-CN/mirror.md | 10 ++++++++-- docs/zh-CN/troubleshooting.md | 4 +++- 8 files changed, 82 insertions(+), 19 deletions(-) diff --git a/docs/changes.md b/docs/changes.md index b52a7fa..a4f4cbe 100644 --- a/docs/changes.md +++ b/docs/changes.md @@ -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) diff --git a/docs/development.md b/docs/development.md index 96a749f..51d35a5 100644 --- a/docs/development.md +++ b/docs/development.md @@ -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 @@ -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/ + vfox-nodejs/`, 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. diff --git a/docs/mirror.md b/docs/mirror.md index 01d3750..cd9ba76 100644 --- a/docs/mirror.md +++ b/docs/mirror.md @@ -57,6 +57,13 @@ 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. @@ -64,8 +71,9 @@ The same layout as `nodejs.org/dist`: 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` | | --- | --- | @@ -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= 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 diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index 5e00ee9..ae8131a 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -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
` means the server has no such file: -the release does not exist (`24.99.0`), or the mirror lacks it. A network error -(`Get "
": 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 "
": 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` @@ -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` diff --git a/docs/zh-CN/changes.md b/docs/zh-CN/changes.md index 6de802a..81b0b5d 100644 --- a/docs/zh-CN/changes.md +++ b/docs/zh-CN/changes.md @@ -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) diff --git a/docs/zh-CN/development.md b/docs/zh-CN/development.md index 4039d97..7ce7a7f 100644 --- a/docs/zh-CN/development.md +++ b/docs/zh-CN/development.md @@ -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 注入对象的类型提示,不会被加载 @@ -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/ vfox-nodejs/`,这些镜像都正常响应。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` 前面。测试把它当作普通函数传入,并断言调用时没有带参数。 diff --git a/docs/zh-CN/mirror.md b/docs/zh-CN/mirror.md index 1e8cf9b..64e0b1d 100644 --- a/docs/zh-CN/mirror.md +++ b/docs/zh-CN/mirror.md @@ -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` | | --- | --- | @@ -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= 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)。 diff --git a/docs/zh-CN/troubleshooting.md b/docs/zh-CN/troubleshooting.md index d5a1a06..66752cc 100644 --- a/docs/zh-CN/troubleshooting.md +++ b/docs/zh-CN/troubleshooting.md @@ -14,7 +14,7 @@ ### `get checksum failed: HTTP 404 from https://nodejs.org/dist/v24.99.0/SHASUMS256.txt` -插件读不到这个版本的 `SHASUMS256.txt`,原因写在冒号后面。`HTTP 404 from
` 表示服务器上没有这个文件:要么这个版本不存在(`24.99.0`),要么镜像里没有它。网络错误(`Get "
": tls: failed to verify certificate: x509: certificate signed by unknown authority`、`... connection refused`、`... EOF`)表示连不上服务器:镜像不可用、代理有问题,或者 TLS 出了问题。见[网络](#网络)。 +插件读不到这个版本的 `SHASUMS256.txt`,原因写在冒号后面。`HTTP 404 from
` 表示服务器上没有这个文件:要么这个版本不存在(`24.99.0`),要么镜像里没有它。镜像可能在 `index.json` 里列出了某个版本、也有它的包,却没有它的 `SHASUMS256.txt`:2026-11-03 的 npmmirror 和华为云对 26.13.0 就是这样。请把 `VFOX_NODEJS_MIRROR` 指向另一个镜像,见 [mirror.md](mirror.md#可用的镜像),或者取消设置,改用 nodejs.org。网络错误(`Get "
": 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` @@ -46,6 +46,8 @@ vfox 没有告诉插件当前运行在哪种 CPU 上。这是不应该出现的 vfox 会打印 `Verifying checksum ...`,拿下载的文件和这个校验和比对,不一致就停下来,并指出它丢弃的文件:`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#使用)。