<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Nvm | 进击之路 - Alan的个人博客</title><link>https://1991421.cn/tag/nvm/</link><atom:link href="https://1991421.cn/tag/nvm/index.xml" rel="self" type="application/rss+xml"/><description>Nvm</description><generator>Hugo Blox Builder (https://hugoblox.com)</generator><language>zh-CN</language><lastBuildDate>Wed, 16 Sep 2026 12:00:00 +0800</lastBuildDate><image><url>https://1991421.cn/media/sharing.png</url><title>Nvm</title><link>https://1991421.cn/tag/nvm/</link></image><item><title>中国区 Node.js 与 nvm 安装及 GitHub 访问方案</title><link>https://1991421.cn/2026/09/16/nodejs-nvm-github-china/</link><pubDate>Wed, 16 Sep 2026 12:00:00 +0800</pubDate><guid>https://1991421.cn/2026/09/16/nodejs-nvm-github-china/</guid><description>&lt;p>在中国网络环境下，GitHub 并不是始终能够正常访问的站点。除了日常下载代码、安装依赖可能失败，部署 Multica 这类依赖 GitHub 资源的工具时，也可能在拉取仓库或安装组件的阶段遇到问题。&lt;/p>
&lt;p>网上常见的解决方案是配置代理，但并不是每台服务器都方便配置网络代理；随意使用网络上来源不明的节点，也可能带来账号、代码和服务器流量被监控等安全隐患。因此，下面只记录一些实际使用后相对可行、配置成本较低的方式。涉及生产环境时，仍然建议优先使用公司批准的网络出口、可信的镜像或自建代理。&lt;/p>
&lt;h2 id="使用国内源安装-nvm">
&lt;a class="heading-anchor-link" href="#%e4%bd%bf%e7%94%a8%e5%9b%bd%e5%86%85%e6%ba%90%e5%ae%89%e8%a3%85-nvm">使用国内源安装 nvm&lt;/a>
&lt;button
class="heading-anchor"
type="button"
data-anchor="使用国内源安装-nvm"
aria-label="复制锚点链接"
title="复制锚点链接"
>
&lt;span class="heading-anchor-wrap" aria-hidden="true">
&lt;svg class="heading-anchor-icon heading-anchor-icon-default" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512" fill="currentColor">
&lt;path d="M0 256C0 167.6 71.6 96 160 96h72c13.3 0 24 10.7 24 24s-10.7 24-24 24H160C98.1 144 48 194.1 48 256s50.1 112 112 112h72c13.3 0 24 10.7 24 24s-10.7 24-24 24H160C71.6 416 0 344.4 0 256zm576 0c0 88.4-71.6 160-160 160H344c-13.3 0-24-10.7-24-24s10.7-24 24-24h72c61.9 0 112-50.1 112-112s-50.1-112-112-112H344c-13.3 0-24-10.7-24-24s10.7-24 24-24h72c88.4 0 160 71.6 160 160zM184 232H392c13.3 0 24 10.7 24 24s-10.7 24-24 24H184c-13.3 0-24-10.7-24-24s10.7-24 24-24z">&lt;/path>
&lt;/svg>
&lt;svg class="heading-anchor-icon heading-anchor-icon-copied" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" fill="currentColor">
&lt;path d="M256 48C141.1 48 48 141.1 48 256s93.1 208 208 208 208-93.1 208-208S370.9 48 256 48zm107.1 145.1L230.6 325.6c-6.2 6.2-16.4 6.2-22.6 0l-59-59c-6.2-6.2-6.2-16.4 0-22.6s16.4-6.2 22.6 0l47.7 47.7 121.1-121.1c6.2-6.2 16.4-6.2 22.6 0s6.3 16.4.1 22.5z">&lt;/path>
&lt;/svg>
&lt;/span>
&lt;/button>
&lt;/h2>&lt;p>官方 nvm 安装脚本通常托管在 GitHub。在无法稳定访问 GitHub 的网络环境中，可以尝试使用 &lt;code>nvm-cn&lt;/code> 提供的安装脚本：&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">bash -c &lt;span class="s2">&amp;#34;&lt;/span>&lt;span class="k">$(&lt;/span>curl -fsSL https://gitee.com/RubyMetric/nvm-cn/raw/main/install.sh&lt;span class="k">)&lt;/span>&lt;span class="s2">&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>安装完成后，重新打开终端，或按照脚本提示加载 Shell 配置文件，然后确认 nvm 是否可用：&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">nvm --version
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>接下来可以安装并切换 Node.js 版本：&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">nvm install --lts
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">nvm use --lts
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">node --version
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">npm --version
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>通过这种方式安装的 nvm 本身会使用国内的 NPM 源，因此通常不需要再单独担心 NPM 包下载问题。实际使用中，如果某个包的源代码或二进制文件仍然托管在 GitHub，安装过程依旧可能受 GitHub 访问情况影响。&lt;/p>
&lt;h2 id="clone-github-仓库">
&lt;a class="heading-anchor-link" href="#clone-github-%e4%bb%93%e5%ba%93">Clone GitHub 仓库&lt;/a>
&lt;button
class="heading-anchor"
type="button"
data-anchor="clone-github-仓库"
aria-label="复制锚点链接"
title="复制锚点链接"
>
&lt;span class="heading-anchor-wrap" aria-hidden="true">
&lt;svg class="heading-anchor-icon heading-anchor-icon-default" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512" fill="currentColor">
&lt;path d="M0 256C0 167.6 71.6 96 160 96h72c13.3 0 24 10.7 24 24s-10.7 24-24 24H160C98.1 144 48 194.1 48 256s50.1 112 112 112h72c13.3 0 24 10.7 24 24s-10.7 24-24 24H160C71.6 416 0 344.4 0 256zm576 0c0 88.4-71.6 160-160 160H344c-13.3 0-24-10.7-24-24s10.7-24 24-24h72c61.9 0 112-50.1 112-112s-50.1-112-112-112H344c-13.3 0-24-10.7-24-24s10.7-24 24-24h72c88.4 0 160 71.6 160 160zM184 232H392c13.3 0 24 10.7 24 24s-10.7 24-24 24H184c-13.3 0-24-10.7-24-24s10.7-24 24-24z">&lt;/path>
&lt;/svg>
&lt;svg class="heading-anchor-icon heading-anchor-icon-copied" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" fill="currentColor">
&lt;path d="M256 48C141.1 48 48 141.1 48 256s93.1 208 208 208 208-93.1 208-208S370.9 48 256 48zm107.1 145.1L230.6 325.6c-6.2 6.2-16.4 6.2-22.6 0l-59-59c-6.2-6.2-6.2-16.4 0-22.6s16.4-6.2 22.6 0l47.7 47.7 121.1-121.1c6.2-6.2 16.4-6.2 22.6 0s6.3 16.4.1 22.5z">&lt;/path>
&lt;/svg>
&lt;/span>
&lt;/button>
&lt;/h2>&lt;p>如果只是需要 clone GitHub 上的资源，可以在目标 GitHub 地址前增加国内代理地址。例如，clone Multica 仓库：&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">git clone --depth &lt;span class="m">1&lt;/span> https://gh-proxy.com/https://github.com/multica-ai/multica.git
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>其中 &lt;code>--depth 1&lt;/code> 只拉取最近的一次提交，可以减少下载量和失败概率。如果 clone 其它 GitHub 仓库，只需要把命令中的 GitHub 地址替换成目标地址：&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">git clone --depth &lt;span class="m">1&lt;/span> https://gh-proxy.com/https://github.com/用户名/仓库名.git
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>代理服务属于第三方基础设施，稳定性、可用性和安全策略都可能变化。不要通过不可信代理传输私有仓库、访问令牌或其它敏感信息；对于私有代码，优先选择可信的镜像、内部制品库或经过审核的网络方案。&lt;/p>
&lt;h2 id="写在最后">
&lt;a class="heading-anchor-link" href="#%e5%86%99%e5%9c%a8%e6%9c%80%e5%90%8e">写在最后&lt;/a>
&lt;button
class="heading-anchor"
type="button"
data-anchor="写在最后"
aria-label="复制锚点链接"
title="复制锚点链接"
>
&lt;span class="heading-anchor-wrap" aria-hidden="true">
&lt;svg class="heading-anchor-icon heading-anchor-icon-default" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512" fill="currentColor">
&lt;path d="M0 256C0 167.6 71.6 96 160 96h72c13.3 0 24 10.7 24 24s-10.7 24-24 24H160C98.1 144 48 194.1 48 256s50.1 112 112 112h72c13.3 0 24 10.7 24 24s-10.7 24-24 24H160C71.6 416 0 344.4 0 256zm576 0c0 88.4-71.6 160-160 160H344c-13.3 0-24-10.7-24-24s10.7-24 24-24h72c61.9 0 112-50.1 112-112s-50.1-112-112-112H344c-13.3 0-24-10.7-24-24s10.7-24 24-24h72c88.4 0 160 71.6 160 160zM184 232H392c13.3 0 24 10.7 24 24s-10.7 24-24 24H184c-13.3 0-24-10.7-24-24s10.7-24 24-24z">&lt;/path>
&lt;/svg>
&lt;svg class="heading-anchor-icon heading-anchor-icon-copied" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" fill="currentColor">
&lt;path d="M256 48C141.1 48 48 141.1 48 256s93.1 208 208 208 208-93.1 208-208S370.9 48 256 48zm107.1 145.1L230.6 325.6c-6.2 6.2-16.4 6.2-22.6 0l-59-59c-6.2-6.2-6.2-16.4 0-22.6s16.4-6.2 22.6 0l47.7 47.7 121.1-121.1c6.2-6.2 16.4-6.2 22.6 0s6.3 16.4.1 22.5z">&lt;/path>
&lt;/svg>
&lt;/span>
&lt;/button>
&lt;/h2>&lt;p>在中国网络环境下，Node.js 和 NPM 的安装不一定需要先解决完整的代理配置：使用国内源安装 nvm，可以覆盖大多数 Node.js 版本管理和 NPM 包安装场景；需要获取公开 GitHub 仓库时，再按需使用可信的国内代理。&lt;/p>
&lt;p>不过，这些方案不能保证长期稳定。遇到下载失败时，先区分是 NPM 源、GitHub 代理，还是某个依赖自己的下载地址出了问题，再选择替代源或网络出口，会比盲目更换节点更安全。&lt;/p></description></item></channel></rss>