MAC:homebrew安装nvm及node
一、安装nvm
终端输入:
brew install nvm
安装完成后会出现提示:
You should create NVM's working directory if it doesn't exist:
mkdir ~/.nvm
Add the following to ~/.zshrc or your desired shell
configuration file:
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
You can set $NVM_DIR to any location, but leaving it unchanged from
/opt/homebrew/opt/nvm will destroy any nvm-installed Node installations
upon upgrade/reinstall.
Type `nvm help` for further information.
根据提示输入创建nvm目录:
mkdir ~/.nvm
编辑 ~/.zshrc 配置文件
①法一:直接在终端编辑(:wq 保存并退出):
vi ~/.zshrc
②法二:找到对应的文件夹(更方便)
在 ~/.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
使用 source 命令使配置生效
source ~/.zshrc
查看配置是否生效
echo $NVM_DIR
查看帮助手册
nvm -help
Note:
to remove, delete, or uninstall nvm - just remove the `$NVM_DIR` folder (usually `~/.nvm`)
删除卸载nvm只需要移除$NVM_DIR文件夹,一般是~/.nvm
查看版本
nvm -v
nvm ls-remote // 查看所有的node可用版本
二、安装node
安装指定版本的node
nvm install 版本号node -vnpm -v
淘宝镜像源
npm config set registry https://registry.npm.taobao.org
来源地址:https://blog.csdn.net/Froth__/article/details/129717748
免责声明:
① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。
② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341