step1:
通過homebrew安裝nvm
> brew install nvm
注意:沒有brew參照我的知乎文章:
你新買的 MacBook air M1 所需的配置工作
但是到這一步并沒有安裝好铅檩,這時(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
———————————————— 版權(quán)聲明:本文為CSDN博主「曹天驕」的原創(chuàng)文章,遵循CC 4.0 BY-SA版權(quán)協(xié)議椎例,轉(zhuǎn)載請(qǐng)附上原文出處鏈接及本聲明。 原文鏈接:https://blog.csdn.net/solocao/article/details/83216819
但添加后并沒有用请祖,還是顯示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 ~/.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
根據(jù)提示配置shell文件即可慎陵。