保姆级mac下载nvm

55 阅读1分钟

mac下载nvm(不需要brew和homebrew)

1.前情提要

要想下载nvm要保证电脑中没有下载node

如果下载node,需要删除node

sudo rm -rf /usr/local/{bin/{node,npm},lib/node_modules/npm,lib/node,share/man/*/node.*}

2.下载nvm

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

下载nvm失误,如果出现以下错误

Untitled.png

可以使用git进行下载

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

3.配置环境变量

vim ~/.bash_profile

将以下内容保存进文件内

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

刷新环境变量

source ~/.bash_profile

4.验证生效

nvm -v

5.举例使用node14

nvm install 14
nvm use 14