登录 注册

nvm (Node.js版本管理器)

去点 Star
其他
95,913
Stars
—
Forks
0
Watchers
—
Open Issues
待补全
许可证
Shell
语言
—
创建时间
最近更新

项目能做什么

符合 POSIX 规范的 Node.js 多版本管理 bash 脚本。
来源:基于仓库元数据 · 内容以仓库实际 README 为准

使用说明 查看原始 README 原仓库文档

项目简介

nvm(Node Version Manager)是一个符合 POSIX 标准的 bash 脚本工具,专为管理多个活跃的 Node.js 版本而设计。它按用户级别安装,并在各个 Shell 会话中独立调用,支持快速安装、切换和管理不同版本的 Node.js 与 npm。

核心功能

  • 多版本安装与无缝切换:通过命令行快速安装指定版本的 Node.js 并即时切换生效。
  • Shell 会话独立性:每个终端会话可独立指定使用不同的 Node.js 版本。
  • 跨平台 POSIX Shell 支持:兼容 sh、dash、ksh、zsh、bash 等 Shell,支持 Unix、macOS 以及 Windows WSL 环境。

基本使用示例:

$ nvm install 24
Now using node v24.14.0 (npm v11.9.0)
$ node -v
v24.14.0
$ nvm use 22
Now using node v22.22.1 (npm v10.9.4)
$ node -v
v22.22.1
$ nvm use 20
Now using node v20.20.1 (npm v10.8.2)
$ node -v
v20.20.1

适合谁用

  • 需要在多套 Node.js 运行时之间频繁切换的前端及全栈开发者。
  • 运行在 macOS、Linux 或 Windows WSL 上的个人开发环境。

安装步骤

可以通过 curl 或 wget 运行官方安装/更新脚本:

使用 curl:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.41.0/install.sh | bash

使用 wget:

wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.41.0/install.sh | bash

该脚本会将 nvm 仓库克隆到本地的 ~/.nvm 目录,并尝试将环境变量加载语句写入对应的配置文件中(如 ~/.bashrc、~/.bash_profile、~/.zshrc 或 ~/.profile)。

配置说明

安装脚本通常会自动写入环境配置。若脚本未自动生效或配置到了错误的文件,需手动将以下内容追加至相应的配置文件(例如 ~/.bashrc 或 ~/.zshrc)中:

(注:具体配置脚本片段在原 README 截断处未完整展示,此部分原文未说明,请查看原仓库)

常见问题

  • Windows 原生支持:nvm 主要面向 POSIX Shell 环境,Windows 用户需在 Windows WSL 环境下使用。
  • 其他故障排查与高级功能(如 Alpine Linux 安装、Docker CI/CD 配置、全局包迁移、.nvmrc 联动等):因原文截断未完整展示,此部分原文未说明,请查看原仓库。
原始 README 摘录(英文原文,节选前 3000 字符)
<a href="https://github.com/nvm-sh/logos">
  <picture>
    <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/nvm-sh/logos/HEAD/nvm-logo-white.svg" />
    <img src="https://raw.githubusercontent.com/nvm-sh/logos/HEAD/nvm-logo-color.svg" height="50" alt="nvm project logo" />
  </picture>
</a>


# Node Version Manager [![Tests](https://github.com/nvm-sh/nvm/actions/workflows/tests-fast.yml/badge.svg?branch=master)][3] [![nvm version](https://img.shields.io/badge/version-v0.41.0-yellow.svg)][4] [![CII Best Practices](https://bestpractices.dev/projects/684/badge)](https://bestpractices.dev/projects/684)

<!-- To update this table of contents, ensure you have run `npm install` then `npm run doctoc` -->
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
## Table of Contents

- [Intro](#intro)
- [About](#about)
- [Installing and Updating](#installing-and-updating)
  - [Install & Update Script](#install--update-script)
    - [Additional Notes](#additional-notes)
    - [Installing in Docker](#installing-in-docker)
      - [Installing in Docker for CICD-Jobs](#installing-in-docker-for-cicd-jobs)
    - [Troubleshooting on Linux](#troubleshooting-on-linux)
    - [Troubleshooting on macOS](#troubleshooting-on-macos)
    - [Ansible](#ansible)
  - [Verify Installation](#verify-installation)
  - [Important Notes](#important-notes)
  - [Git Install](#git-install)
  - [Manual Install](#manual-install)
  - [Manual Upgrade](#manual-upgrade)
- [Usage](#usage)
  - [Long-term Support](#long-term-support)
  - [Version Categories](#version-categories)
  - [Migrating Global Packages While Installing](#migrating-global-packages-while-installing)
  - [Migrating Global Packages Between Installed Versions](#migrating-global-packages-between-installed-versions)
  - [Offline Install](#offline-install)
  - [Default Global Packages From File While Installing](#default-global-packages-from-file-while-installing)
  - [io.js](#iojs)
  - [System Version of Node](#system-version-of-node)
  - [Listing Versions](#listing-versions)
  - [Setting Custom Colors](#setting-custom-colors)
    - [Persisting custom colors](#persisting-custom-colors)
    - [Suppressing colorized output](#suppressing-colorized-output)
  - [Restoring PATH](#restoring-path)
  - [Set default node version](#set-default-node-version)
  - [Use a mirror of node binaries](#use-a-mirror-of-node-binaries)
    - [Pass Authorization header to mirror](#pass-authorization-header-to-mirror)
  - [Platforms without official binaries](#platforms-without-official-binaries)
  - [.nvmrc](#nvmrc)
  - [Deeper Shell Integration](#deeper-shell-integration)
    - [Calling `nvm use` automatically in a directory with a `.nvmrc` file](#calling-nvm-use-automatically-in-a-directory-with-a-nvmrc-file)
      - [bash](#bash)
      - [zsh](#zsh)
      - [fish](#fish)
- [Running Tests](#running-tests)
- [Environment va
阅读完整原文

项目深度分析 规则生成(AI 未配置)

综合评分 38.0 分。该项目在“个人可实施性”维度得 35 分,“付费可能性”维度得 20.0 分,差异化空间 40.0 分(评分依据见评分卡)。

面向细分需求的二次开发产品

产品构想基于 nvm 的核心能力,聚焦一个更窄的场景(如某平台、某行业)做差异化。
目标用户该细分场景用户
难度/周期中 · 2~6 周
收费模式买断制 / 订阅制 / 广告
竞争风险细分需求规模需验证
依据 AI 推测:基于项目主题标签的判断
以上为规则引擎基于仓库公开数据生成的参考结论,包含推测成分,不构成投资或创业承诺;配置 AI 后可获得更深入的分析。
报告会保存到 个人中心

竞品与相似项目 GitHub Search 真实检索

以上为通过 GitHub 官方 Search API 检索的相似项目,功能差异与优劣势需进一步人工确认,配置 AI 后可生成对比分析。

项目优势与风险

技术成熟度创建时间待补全,最近推送 ,发布过 76 个 Release
社区活跃Star 95,913 / Fork 0 / Issue 0(数据支持,可自行核实)
许可证未检测到(需人工确认)
主要风险上游项目方向可能变化;同赛道竞争者较多(见竞品表);热度与需求不完全等价

安装与使用

此项目未提供 Docker 镜像,安装步骤以原仓库 README 为准(涉及依赖安装与环境配置,对新手门槛较高)。