Nodejs Release 为各平台提供预编译的 nodejs 和 npm 等二进制文件,是 https://nodejs.org/dist/ 的镜像。
可以手工选择下载所需的版本,也可以搭配 n 或者 fnm 等版本管理器使用,方法如下:
# 设定环境变量
export NODE_MIRROR=https://mirrors.tuna.tsinghua.edu.cn/nodejs-release/
# 然后正常使用 n 即可
n stable # 设定环境变量
export FNM_NODE_DIST_MIRROR=https://mirrors.tuna.tsinghua.edu.cn/nodejs-release/
# 然后正常使用 fnm 即可
fnm install <version> 创建或编辑 ~/.volta/hooks.json (Linux/MacOS),或 %LOCALAPPDATA%\Volta\hooks.json (Windows),将内容替换如下
{
"node": {
"index": {
"template": "https://mirrors.tuna.tsinghua.edu.cn/nodejs-release/index.json"
},
"distro": {
"template": "https://mirrors.tuna.tsinghua.edu.cn/nodejs-release/v{{version}}/{{filename}}"
}
}
} 之后即可正常使用 volta
volta install node@<version>volta install node@<version>
# 设定环境变量
export NVM_NODEJS_ORG_MIRROR=https://mirrors.tuna.tsinghua.edu.cn/nodejs-release/
# 然后正常使用
nvm install <version> nvs remote node https://mirrors.tuna.tsinghua.edu.cn/nodejs-release/ mise settings node.mirror_url=https://mirrors.tuna.tsinghua.edu.cn/nodejs-release/