惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Secure Thoughts
Security Latest
Security Latest
Simon Willison's Weblog
Simon Willison's Weblog
O
OpenAI News
GbyAI
GbyAI
L
LINUX DO - 最新话题
A
Arctic Wolf
T
Tor Project blog
G
GRAHAM CLULEY
I
InfoQ
博客园_首页
IT之家
IT之家
The Register - Security
The Register - Security
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Proofpoint News Feed
The GitHub Blog
The GitHub Blog
Blog — PlanetScale
Blog — PlanetScale
N
Netflix TechBlog - Medium
K
Kaspersky official blog
博客园 - 三生石上(FineUI控件)
S
SegmentFault 最新的问题
U
Unit 42
PCI Perspectives
PCI Perspectives
量子位
P
Palo Alto Networks Blog
S
Securelist
T
Troy Hunt's Blog
博客园 - 【当耐特】
Recorded Future
Recorded Future
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
S
Security Affairs
Engineering at Meta
Engineering at Meta
T
The Blog of Author Tim Ferriss
博客园 - 聂微东
罗磊的独立博客
N
News and Events Feed by Topic
人人都是产品经理
人人都是产品经理
B
Blog RSS Feed
NISL@THU
NISL@THU
C
Cisco Blogs
T
Threatpost
有赞技术团队
有赞技术团队
Forbes - Security
Forbes - Security
Hugging Face - Blog
Hugging Face - Blog
Last Week in AI
Last Week in AI
T
The Exploit Database - CXSecurity.com
Cloudbric
Cloudbric
Cyberwarzone
Cyberwarzone
Google DeepMind News
Google DeepMind News
C
Cyber Attacks, Cyber Crime and Cyber Security

博客园 - 君临天下之徐少

Homebrew 安装 Less的优点 什么是nrm js 处理大数相减 React函数式组件值之useRef()和useImperativeHandle() 谷歌刷题插件安装 SSL certificate problem: unable to get local issuer certificate 错误解决 常用命令 Mac安装Nvm Node开发环境 解决Mac安装Homebrew失败 Canvas学习:globalCompositeOperation详解 React.CreateContext html让容器居中,css让容器水平垂直居中的7种方式 js下载文件防止白屏 GitHub上README.md编写教程(基本语法) 微信字体大小调整导致的H5页面错乱问题处理 G6-Editor 编辑器入门使用教程 git reset 加不加 --hard的区别 taro, h5拨打电话和发送短信
nvm安装
君临天下之徐少 · 2026-04-02 · via 博客园 - 君临天下之徐少

在Mac上安装Node Version Manager(NVM)是管理和安装Node.js版本的简便方式。NVM允许你安装多个版本的Node.js,并在它们之间轻松切换。以下是安装NVM的步骤:

方法1:使用Homebrew

如果你还没有安装Homebrew,可以通过以下命令安装:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

安装完Homebrew后,使用以下命令安装NVM:

方法2:使用Git和脚本安装

如果你偏好不使用Homebrew,可以通过Git和脚本手动安装NVM:

  1. 首先,安装Git(如果尚未安装):
  1. 安装nvm:

git clone https://github.com/nvm-sh/nvm.git ~/.nvm

  1. 在你的.bash_profile.zshrc.profile或相应的shell配置文件中添加以下行(根据你的shell选择相应的配置文件):

export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"

  1. 重新加载配置文件或打开一个新的终端窗口以应用更改:

source ~/.bash_profile # 或 source ~/.zshrc,取决于你使用的是哪种shell

方法3:使用 curl 安装

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

方法4:使用 wget 安装

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

配置环境变量

安装完成后,将以下内容添加到 ~/.bashrc~/.zshrc 或 ~/.profile 中:

export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"

然后执行:

source ~/.bashrc # 或 source ~/.zshrc

验证安装

安装完成后,你可以通过运行以下命令来检查NVM是否正确安装:

这应该会显示NVM的版本号。

使用NVM安装Node.js版本

现在你可以使用NVM来安装Node.js的特定版本了。例如,要安装Node.js的最新稳定版本,可以使用:

nvm install node # 安装最新稳定版Node.js

或者,指定一个特定的版本号:

nvm install 14.17.0 # 安装特定版本的Node.js,例如14.17.0版本

切换Node.js版本

安装多个Node.js版本后,你可以使用以下命令来切换版本:

nvm use 14.17.0 # 切换到14.17.0版本

或者,使用:

nvm use node # 切换到最新稳定版Node.js

通过以上步骤,你应该能够在Mac上成功安装并使用NVM来管理Node.js版本。