首先安装homebrew
https://blog.csdn.net/qq1808814025/article/details/112667458这个哥的比较厉害
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash
如果正常安装 就继续安装所需
安装的时候报错了 curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused
修改地方 系统偏好设置—》网络—〉高级 -DNS 改为8.8.8.8
运行如缺少.bash_profile 就进入Users下vim .bash_profile 并添加如下
exportNVM_DIR="$HOME/.nvm"
[ -s"$NVM_DIR/nvm.sh"] && \."$NVM_DIR/nvm.sh"# This loads nvm
[ -s"$NVM_DIR/bash_completion"] && \."$NVM_DIR/bash_completion"
source .bash_profile //让配置文件生效
nvm安装node 下载太慢命令行输入以下代码即可:
NVM_NODEJS_ORG_MIRROR=https://npm.taobao.org/mirrors/node
Mac M1安装 nvm 遇到的坑
step1:
通过homebrew安装nvm
> brew install nvm
注意:没有brew参照我的知乎文章:
但是到这一步并没有安装好,这时直接使用nvm指令会得到:
> nvm zsh: command not found: nvm
网上一些教程会告诉你要在 shell 文件(我是用的zsh,所以在~/.zshrc)中添加:
export NVM_DIR="
NVM_DIR/nvm.sh" ] && . "
NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion" # This loads nvm bash_completion
但添加后并没有用,还是显示command not found:nvm。原因是M1之后,homebrew不能放到 /usr/local/bin目录下了,要放到/opt目录下,所以以上指令要针对本地安装目录。
step2:
> brew info nvm
会根据你本机的配置情况得到相应的安装提示:
You should create NVM's working directory if it doesn't exist: mkdir ~/.nvmAdd the following to ~/.zshrc or your desired shellconfiguration 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
根据提示配置shell文件即可。
转自 https://www.jianshu.com/p/e945bb48593e
网友评论