新mac安装nvm喂饭级教程

366 阅读1分钟

首先安装homebrew

供参考文章 juejin.cn/post/684490…

执行命令

国内:

/bin/zsh -c "$(curl -fsSLhttps://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"

安装好以后进行下载

brew install nvm

安装成功之后,还不能直接使用nvm命令,需要进行以下配置,将以下命令复制到终端执行:

echo "source $(brew --prefix nvm)/nvm.sh" >> .bash_profile

修改之后,需要重新定向来源,复制以下命令并执行:

. ~/.bash_profile

此时在终端输入:

nvm list

有发现不太行的时候 就只能找文件夹配置了 首先在桌面找到访达

image.png

接下来 在栏目中勾选

image.png

接下来打开finder 在里面显示隐藏文件

image.png

image.png

一切都准备好了以后。。。

.zshrc 里写入

export NVM_DIR=~/.nvm
source $(brew --prefix nvm)/nvm.sh
source ~/.bash_profile

.bash_profile 里写入

export NVM_DIR=~/.nvm
export NVM_NODEJS_ORG_MIRROR=https://nodejs.org/dist
# export NVM_NODEJS_ORG_MIRROR=https://npm.taobao.org/mirrors/node/
source $(brew --prefix nvm)/nvm.sh

最后刷一下

source ~/.zshrc

就成功了