安装nvm

brew install nvm

安装成功后会出现这样一段话:

Add the following to your shell profile e.g. ~/.profile or ~/.zshrc:
  export NVM_DIR="$HOME/.nvm"
  [ -s "/opt/homebrew/opt/nvm/nvm.sh" ] && \. "/opt/homebrew/opt/nvm/nvm.sh"  # This loads nvm
  [ -s "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" ] && \. "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm"  # This loads nvm bash_completion

把这段话拷贝到 ~/.bash_profile中

vim ~/.bash_profile

即拷贝下面这段话

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

然后让配置生效

source ~/.bash_profile

输入nvm -v就能看到安装版本了。


记得装个镜像,但mac homebrew安装我暂时找不到nvm安装目录(TODO)

npm的镜像设置可参考 pip镜像管理和npm镜像管理

常用命令

nvm install x.x.x

例如安装20.2.5版本的node

nvm install 20.2.5

点赞(0) 打赏

评论列表 共有 0 条评论

暂无评论

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部