一、nvm安装
要在 macOS 上安装 NVM(Node Version Manager),可以按照以下步骤进行操作:
-
打开终端:你可以在“应用程序”文件夹中的“实用工具”文件夹中找到“终端”应用程序。
-
安装 Homebrew(如果尚未安装):在终端中运行以下命令来安装 Homebrew:
shellCopy code
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
-
安装 NVM:在终端中运行以下命令使用 Homebrew 安装 NVM:
brew install nvm
-
配置 NVM:NVM 需要将其初始化脚本添加到你的 shell 配置文件(如
.bash_profile
、.zshrc
等)。运行以下命令将其添加到当前用户的.bash_profile
文件:echo 'export NVM_DIR="$HOME/.nvm"' >> ~/.bash_profile echo 'source $(brew --prefix nvm)/nvm.sh' >> ~/.bash_profile
如果你使用的是 Zsh shell,将上述命令中的
.bash_profile
替换为.zshrc
。 -
刷新 shell 配置:运