一、安装nvm 终端输入: brew install nvm 安装完成后会出现提示: You should create NVM's working directory if it doesn't exist: mkdir
终端输入:
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
nvm install 版本号node -vnpm -v
淘宝镜像源
npm config set reGIStry https://registry.npm.taobao.org
来源地址:https://blog.csdn.net/Froth__/article/details/129717748
--结束END--
本文标题: MAC:homebrew安装nvm及node
本文链接: https://lsjlt.com/news/397345.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-01-21
2023-10-28
2023-10-28
2023-10-27
2023-10-27
2023-10-27
2023-10-27
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0