Files
nexus/wiki/concepts/nvm.md
2026-04-17 08:38:12 +08:00

34 lines
791 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: "nvm"
type: concept
tags: [node-js, version-manager]
last_updated: 2026-04-17
---
## 定义
nvmNode Version Manager是 Node.js 版本管理工具,允许在同一系统上安装和切换多个 Node.js 版本。
## 用途
- 安装指定版本的 Node.js
- 快速切换不同 Node 版本
- 避免全局 npm 包的版本冲突
- 使用非 root 用户安全安装 Node
## 安装方法
```bash
curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
```
## 常用命令
```bash
nvm install 20 # 安装 Node 20
nvm use 20 # 切换到 Node 20
nvm alias default 20 # 设置默认版本
nvm list # 列出已安装版本
```
## 关联
- 基于:[[Shell]]
- 管理对象:[[Node-js]]
- 配合工具:[[npm]]、[[npx]]