HomeBrew安裝
-
官網(wǎng)安裝
網(wǎng)址:https://brew.sh/
安裝:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"卸載:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)" -
國(guó)內(nèi)鏡像安裝【推薦】
有選擇國(guó)內(nèi)源的選項(xiàng),檢查Git環(huán)境是否設(shè)置代理等
安裝:
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"卸載:
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/HomebrewUninstall.sh)" 常用命令
安裝軟件:brew install xxx
卸載軟件:brew uninstall xxx
搜索軟件:brew search xxx
更新軟件:brew upgrade xxx
查看列表:brew list
更新brew:brew update
清理所有包的舊版本:brew cleanup
清理指定包的舊版本:brew cleanup $FORMULA
查看可清理的舊版本包,不執(zhí)行實(shí)際操作:brew cleanup -n
Git 設(shè)置代理 加速pod install等
-
全局設(shè)置代理
git config --global http.proxy socks5://127.0.0.1:1080 -
僅GitHub設(shè)置代理,國(guó)內(nèi)Git不設(shè)置
git config --global http.https://github.com.proxy socks5://127.0.0.1:1080 -
取消代理
git config --global --unset http.proxygit config --global --unset http.https://github.com.proxy
nvm安裝與使用
在不同項(xiàng)目中可能使用不同的node版本,可以使用NVM(node.js version management)來(lái)管理node版本
-
安裝nvm之前先檢查電腦是否有安裝過(guò)node,卸載之前安裝的node,使用nvm重新install node版本進(jìn)行管理
sudo rm -rf /usr/local/{bin/{node,npm},lib/node_modules/npm,lib/node,share/man/*/node.*} -
安裝
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash
執(zhí)行之后使用nvm --version查看是否安裝成功,如提示找不到nvm:command not found: nvm則配置環(huán)境變量,以Mac為例
如使用bash,則
sudo vim ~/.bash_profile(zsh 則sudo vim ~/.zshrc) 打開(kāi)編輯模式,將如下例環(huán)境變量添加其中,最后source ~/.bash_profile使其生效
[ -s "$NVM_DIR/nvm.sh" ] && \."$NVM_DIR/nvm.sh" # This loadsnvm
[ -s "$NVM_DIR/bash_completion" ] && \."$NVM_DIR/bash_completion" #This loads nvm bash_completion
- nvm常用命令
nvm install stable #安裝最新穩(wěn)定版 node
nvm install <version> #安裝指定版本,如:安裝v4.4.0,nvm install v4.4.0
nvm uninstall <version> #刪除已安裝的指定版本,語(yǔ)法與install類似
nvm use <version> #切換使用指定的版本node(臨時(shí))
nvm ls #列出所有安裝的版本
nvm alias default <version> #切默認(rèn)版本如: nvm alias default v11.1.0