欢迎来到刘认真的博客

It's not me that's wrong. It's the whole world

mac npm 无法使用时 zsh配置

更新:建议使用nvm官方GitHub文档安装方式

参考文档:https://github.com/nvm-sh/nvm/blob/master/README.md#installing-and-updating


安装brew

终端上运行

$ /usr/bin/ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”

安装NVM

$ brew install nvm

安装完成之后打开shell的配置文件

$ cd ~
$ vim ~/.zshrc

# 如果是bash的话执行
$ vim .bash_profile

在文件里添加以下命令

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

然后重新source

$ source ~/.zshrc

# 如果是bash的话执行
$ source .bash_profile

使用nvm安装node

$ nvm ls-remote 查看 所有的node可用版本
$ nvm install xxx 下载你想要的版本
$ nvm use xxx 使用指定版本的node
$ nvm alias default xxx 每次启动终端都使用该版本的node
 
 
 
posted @ 2020-09-16 09:56  刘认真  阅读(703)  评论(0编辑  收藏  举报