首先安裝homebrew?
https://blog.csdn.net/qq1808814025/article/details/112667458這個(gè)哥的比較厲害
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash
如果正常安裝 就繼續(xù)安裝所需?
安裝的時(shí)候報(bào)錯(cuò)了 curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused
修改地方 系統(tǒng)偏好設(shè)置—》網(wǎng)絡(luò)—〉高級(jí) -DNS 改為8.8.8.8
運(yùn)行如缺少.bash_profile? ?就進(jìn)入U(xiǎn)sers下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參照我的知乎文章:
但是到這一步并沒有安裝好哨毁,這時(shí)直接使用nvm指令會(huì)得到:
> nvm zsh: command not found: nvm
網(wǎng)上一些教程會(huì)告訴你要在 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目錄下稍算,所以以上指令要針對(duì)本地安裝目錄。
step2:
> brew info nvm
會(huì)根據(jù)你本機(jī)的配置情況得到相應(yīng)的安裝提示:
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
根據(jù)提示配置shell文件即可墨技。
轉(zhuǎn)自?http://www.reibang.com/p/e945bb48593e