最近推送 2026-11-12 13:50(18 天前),属于活跃维护
nvm-sh/nvm
GITHUB中文整理主语言 Shell · 96,217 星 · MIT · 创建于 2010-04-16
Node.js 版本管理器,以 Bash 脚本实现,按用户安装并按 Shell 调用,用于管理多个活跃的 Node.js 版本。
仓库健康度
5 个维度开放 Issue 373 个 · Fork 10,755 个
24 小时 +0 · 7 日 +0 · 30 日 积累中
许可证 MIT · 12 个 topics
这一项暂无数据,不代表项目没有发布
「证据不足」表示这项数据暂时没有取到,不能读成「项目有问题」;「部分数据」表示只拿到一部分信号。版本发布要额外调 Releases 接口,下一版补。
Star 趋势
20 天记录横轴 2026-11-12 → 2026-12-01,纵轴按这段时间的最小/最大值拉伸。趋势来自站内每天记录一次的星数,页面打开时不会实时请求 GitHub。
它解决什么问题
据 README 归纳开发中常需切换不同 Node.js 版本,手动管理繁琐且易出错。没有它,需自行下载、切换二进制或全局替换,难以在同一台机器上灵活并行使用多个版本。
核心能力
6 条- 1安装多个 Node.js 版本
- 2按需切换当前活跃版本
- 3按用户安装并按 Shell 调用
- 4兼容多种 POSIX Shell
- 5提供安装与更新脚本
- 6可通过环境变量自定义安装
项目画像
6 个角度项目定位
Node.js 版本管理器,以 Bash 脚本实现,按用户安装并按 Shell 调用,用于管理多个活跃的 Node.js 版本。
适合谁
需要同时使用或频繁切换多个 Node.js 版本的开发者,尤其是 Web 前端、Node.js 后端开发,以及多项目并行维护的人员。
典型场景
在本地开发中,为不同项目安装并切换所需 Node.js 版本;在 CI/CD 的交互或非交互容器中管理 Node.js 环境;为某个项目临时使用指定 Node.js 版本而不影响全局
部署难度
安装需运行脚本,该脚本克隆仓库并修改 Shell 配置文件;需预先有 curl/wget/git 及一个 POSIX 兼容 Shell;之后重启终端或手动 source 即生效。
风险限制
依赖 POSIX 兼容 Shell 和 curl/wget/git;仅限 Unix、macOS、Windows WSL;安装后需重启终端或重新加载 Shell;非交互式 Shell 需额外配置 BASH_ENV。
最近维护
最近一次推送是 2026-11-12 13:50。 实现方式:以 Shell 函数形式在 Shell 中加载,通过修改环境变量和路径来切换 Node.js 版本;安装脚本将仓库克隆到用户目录并配置 Shell 启动文件。
README 原文细节
1 个板块怎么安装从零跑起来的步骤
Install & Update Script
To install or update nvm, you should run the [install script][2]. To do that, you may either download and run the script manually, or use the following cURL or Wget command:
Running either of the above commands downloads a script and runs it. The script clones the nvm repository to ~/.nvm, and attempts to add the source lines from the snippet below to the correct profile file (~/.bashrc, ~/.bashprofile, ~/.zshrc, or ~/.profile). If you find the install script is updating the wrong profile file, set the $PROFILE env var to the profile file’s path, and then rerun the installation script.
When invoking bash as a non-interactive shell, like in a Docker container, none of the regular profile files are sourced. In order to use nvm, node, and npm like normal, you can instead specify the special BASHENV variable, which bash sources when invoked non-interactively.
More robust, works in CI/CD-Jobs. Can be run in interactive and non-interactive containers. See https://github.com/nvm-sh/nvm/issues/3531.
- If the environment variable $XDGCONFIGHOME is present, it will place the nvm files there.
- You can add --no-use to the end of the above script to postpone using nvm until you manually use it:
- You can customize the install source, directory, profile, and version using the NVMSOURCE, NVMDIR, PROFILE, and NODEVERSION variables.
- Eg: curl ... | NVMDIR="path/to/nvm". Ensure that the NVMDIR does not contain a trailing slash.
- The installer can use git, curl, or wget to download nvm, whichever is available.
- You can instruct the installer to not edit your shell config (for example if you already get completions via a zsh nvm plugin) by setting PROFILE=/dev/null before running the install.sh script. Here's
- Since macOS 10.15, the default shell is zsh and nvm will look for .zshrc to update, none is installed by default. Create one with touch ~/.zshrc and run the install script again.
- If you use bash, the previous default shell, your system may not have .bashprofile or .bashrc files where the command is set up. Create one of them with touch ~/.bashprofile or touch ~/.bashrc and run
- You have previously used bash, but you have zsh installed. You need to manually add these lines to ~/.zshrc and run . ~/.zshrc.
- You might need to restart your terminal instance or run . ~/.nvm/nvm.sh. Restarting your terminal/opening a new tab/window, or running the source command will load the command and the new configuratio
- If the above didn't help, you might need to restart your terminal instance. Try opening a new tab/window in your terminal and retry.
- If you use bash, it may be that your .bashprofile (or ~/.profile) does not source your ~/.bashrc properly. You could fix this by adding source ~/ to it or following the next step below.
- Try adding the snippet from the install section, that finds the correct nvm directory and loads nvm, to your usual profile (~/.bashprofile, ~/.zshrc, ~/.profile, or ~/.bashrc).
- For more information about this issue and possible workarounds, please refer here
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.41.0/install.sh | bash
Verify Installation
which should output nvm if the installation was successful. Please note that which nvm will not work, since nvm is a sourced shell function, not an executable binary.
Note: On Linux, after running the install script, if you get nvm: command not found or see no feedback from your terminal after you type command -v nvm, simply close your current terminal, open a new terminal, and try verifying again.
command -v nvm
Git Install
Now add these lines to your ~/.bashrc, ~/.profile, or ~/.zshrc file to have it automatically sourced upon login: (you may have to add to more than one of the above files)
- clone this repo in the root of your user profile
- cd ~/ from anywhere then git clone https://github.com/nvm-sh/nvm.git .nvm
- cd ~/.nvm and check out the latest version with git checkout v0.41.0
- activate nvm by sourcing it from your shell: . ./nvm.sh
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
Manual Install
For a fully manual install, execute the following lines to first clone the nvm repository into $HOME/.nvm, and then load nvm:
Now add these lines to your ~/.bashrc, ~/.profile, or ~/.zshrc file to have it automatically sourced upon login: (you may have to add to more than one of the above files)
export NVM_DIR="$HOME/.nvm" && (
git clone https://github.com/nvm-sh/nvm.git "$NVM_DIR"
cd "$NVM_DIR"
git checkout `git describe --abbrev=0 --tags --match "v[0-9]*" $(git rev-list --tags --max-count=1)`
) && \. "$NVM_DIR/nvm.sh"
Migrating Global Packages While Installing
If you want to install a new version of Node.js and migrate npm packages from a previous version:
This will first use "nvm version node" to identify the current version you're migrating packages from. Then it resolves the new version to install from the remote server and installs it. Lastly, it runs "nvm reinstall-packages" to reinstall the npm packages from your prior version of Node to the new one.
You can also install and migrate npm packages from specific versions of Node like this:
Note that reinstalling packages explicitly does not update the npm version — this is to ensure that npm isn't accidentally upgraded to a broken version for the new node version.
nvm install --reinstall-packages-from=node node
Migrating Global Packages Between Installed Versions
--reinstall-packages-from is tied to nvm install. To migrate global npm packages between versions you already have installed, without (re)installing anything, nvm use the destination and run nvm reinstall-packages as a standalone command, pointing at the version you want to copy from:
This reinstalls all global packages from 22.20.0 into the currently-active version (22.22.2). As with --reinstall-packages-from, the npm version itself is not changed.
nvm use 22.22.2
nvm reinstall-packages 22.20.0
Offline Install
If you've previously downloaded a node version (or it's still in the cache), you can install it without any network access using the --offline flag:
This resolves versions using only locally installed versions and cached downloads. It will not attempt to download anything. This is useful in air-gapped environments, on planes, or when you want to avoid network latency.
A download is only added to the cache ($NVMDIR/.cache) once its checksum has been verified. --offline does not verify cached archives again, so anything placed in the cache by other means is trusted as-is.
You can combine --offline with --lts to install the latest cached LTS version (as long as LTS aliases have been populated by a prior nvm ls-remote --lts):
nvm install --offline 14.7.0
Default Global Packages From File While Installing
If you have a list of default packages you want installed every time you install a new version, we support that too -- just add the package names, one per line, to the file $NVMDIR/default-packages. You can add anything npm would accept as a package argument on the command line.
# $NVM_DIR/default-packages
rimraf
object-inspect@1.0.2
stevemao/left-pad
关于 nvm 的常见问题
7 个问题nvm 是做什么的?
Node.js 版本管理器,以 Bash 脚本实现,按用户安装并按 Shell 调用,用于管理多个活跃的 Node.js 版本。 开发中常需切换不同 Node.js 版本,手动管理繁琐且易出错。没有它,需自行下载、切换二进制或全局替换,难以在同一台机器上灵活并行使用多个版本。
nvm 有哪些功能?
核心能力:安装多个 Node.js 版本;按需切换当前活跃版本;按用户安装并按 Shell 调用;兼容多种 POSIX Shell;提供安装与更新脚本;可通过环境变量自定义安装。
nvm 适合谁用?
需要同时使用或频繁切换多个 Node.js 版本的开发者,尤其是 Web 前端、Node.js 后端开发,以及多项目并行维护的人员。
nvm 是怎么工作的?
以 Shell 函数形式在 Shell 中加载,通过修改环境变量和路径来切换 Node.js 版本;安装脚本将仓库克隆到用户目录并配置 Shell 启动文件。
怎么安装 nvm?
按项目 README 的说明:If the environment variable $XDGCONFIGHOME is present, it will place the nvm files there.;You can add --no-use to the end of the above script to postpone using nvm until you manually use it:;You can customize the install source, directory, profile, and version using the NVMSOURCE, NVMDIR, PROFILE, and NODEVERSION variables.;Eg: curl ... | NVMDIR="path/to/nvm". Ensure that the NVMDIR does not contain a trailing slash.。完整命令见下方「怎么安装」一节或 GitHub 仓库的 README。
用 nvm 有什么门槛或限制?
依赖 POSIX 兼容 Shell 和 curl/wget/git;仅限 Unix、macOS、Windows WSL;安装后需重启终端或重新加载 Shell;非交互式 Shell 需额外配置 BASH_ENV。
nvm 现在还在维护吗?数据怎么样?
目前 96,217 星,10,755 个 Fork,主语言 Shell,创建于 2010-04-16,最近一次推送 2026-11-12 13:50,许可证 MIT。星数、Fork、推送时间都是 GitHub 返回的实时数据,「最近推送」离现在越近说明越活跃;长期不动要留意是否已停止维护。
这些内容来自哪
读法说明项目数据取自 GitHub 官方接口与项目 README;星数、Fork、语言与时间以 GitHub 页面为准,档案更新于 2026-11-13 00:15。