上一篇:《uniapp 通知开发》
1、 homebrew包管理器
其他包管理器以及区别:
brew cask 和 formulae的区别
Formulae:软件包,包括了这个软件的依赖、源码位置及编译方法等;
Casks:已经编译好的应用包,如图形界面程序等。
#官网安装脚本 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.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 install --cask xxx #卸载: brew uninstall xxx #搜索: brew search xxx #检查哪些软件需要更新 brew outdated #更新: brew upgrade xxx #列表: brew list #更新brew: brew update #清理所有旧版本包 brew cleanup #清理指定包的旧版本 brew cleanup $FORMULAE #查看可清理的旧版本包,不执行实践操作 brew cleanup -n #启动 brew services start xxx #停止 brew services stop xxx #重启 brew services restart xxx #取消安装时自动更新(写入配置到.zsh或者.bash_profile) echo 'export HOMEBREW_NO_AUTO_UPDATE=true' >> ~/.bash_profile source ~/.bash_profile #替换现有源 git -C "$(brew --repo)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git brew update #还原为官方源 git -C "$(brew --repo)" remote set-url origin https://github.com/Homebrew/brew.git git -C "$(brew --repo homebrew/core)" remote set-url origin https://github.com/Homebrew/homebrew-core.git git -C "$(brew --repo homebrew/cask)" remote set-url origin https://github.com/Homebrew/homebrew-cask.git brew update
2、卸载node 自己手动安装的node很麻烦,需要执行以下命令:
cd /usr/local/bin rm -rf node rm -rf npm rm -rf npx rm -rf npm 删除以上四个包都,因为与node相关 sudo rm -rf /usr/local/lib/node_modules sudo rm -rf /usr/local/lib/node sudo rm -rf /usr/local/lib/dtrace/node.d 删除以上三个 sudo rm /usr/local/bin/node 删除以上一个bin文件夹下的node sudo rm /usr/local/share/man/man1/node.1 sudo rm /usr/local/share/man/man1/npm-* sudo rm /usr/local/share/man/man1/npm.1 sudo rm /usr/local/share/man/man1/npx.1 等 删除/usr/local/share/man/man1下和node有关的文件 以上基本就好了, node -v npm -v cnpm -v 都没了
3、安装nvm
brew install nvm
安装日志:
==> Auto-updating Homebrew... Adjust how often this is run with HOMEBREW_AUTO_UPDATE_SECS or disable with HOMEBREW_NO_AUTO_UPDATE. Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`). ==> Auto-updated Homebrew! Updated 2 taps (homebrew/core and homebrew/cask). ==> New Formulae acronym hgrep parlay starlark-rust atac jwt-cli pipelight swctl azurehound kool pixi-pack synchrony bender languagetool-rust pscale talosctl cargo-public-api leetcode-cli qbec tomcat@10 cargo-shuttle legba rapidyaml tuisky codevis libkeyfinder replxx typeshare dry limbo reveal-md tzdb glaze malcontent s5cmd vals go-blueprint mdz sendme wails gopeed mmdbctl sentry-cli watcher gsan neverest slepc gurk oranda slepc-complex heroku parca slumber ==> New Casks bindiff font-ponomar bookmacster@beta font-shafarik dehesselle-meld font-tagesschrift font-moralerspace font-triodion font-moralerspace-hw font-udev-gothic-hs font-moralerspace-hw-jpdoc mouseless font-moralerspace-hw-nf rode-virtual-channels font-moralerspace-jpdoc soundsource@test font-moralerspace-nf stratoshark font-pochaevsk superwhisper Warning: You are using macOS 12. We (and Apple) do not provide support for this old version. It is expected behaviour that some formulae will fail to build in this old version. It is expected behaviour that Homebrew will be buggy and slow. Do not create any issues about this on Homebrew's GitHub repositories. Do not create any issues even if you think this message is unrelated. Any opened issues will be immediately closed without response. Do not ask for help from Homebrew or its maintainers on social media. You may ask for help in Homebrew's discussions but are unlikely to receive a response. Try to figure out the problem yourself and submit a fix as a pull request. We will review it but may or may not accept it. ==> Fetching nvm ==> Downloading https://mirrors.aliyun.com/homebrew/homebrew-bottles/nvm-0.40.1. ######################################################################### 100.0% ==> Pouring nvm-0.40.1.all.bottle.tar.gz ==> Caveats Please note that upstream has asked us to make explicit managing nvm via Homebrew is unsupported by them and you should check any problems against the standard nvm install method prior to reporting. You should create NVM's working directory if it doesn't exist: mkdir ~/.nvm Add the following to your shell profile e.g. ~/.profile or ~/.zshrc: export NVM_DIR="$HOME/.nvm" [ -s "/usr/local/opt/nvm/nvm.sh" ] && \. "/usr/local/opt/nvm/nvm.sh" # This loads nvm [ -s "/usr/local/opt/nvm/etc/bash_completion.d/nvm" ] && \. "/usr/local/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 /usr/local/Cellar/nvm/0.40.1 will destroy any nvm-installed Node installations upon upgrade/reinstall. Type `nvm help` for further information. Bash completion has been installed to: /usr/local/etc/bash_completion.d ==> Summary /usr/local/Cellar/nvm/0.40.1: 10 files, 202.9KB ==> Running `brew cleanup nvm`... Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP. Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
接着要按日志里面的提示
vim ~/.zshrc 按i进入编辑模式 复制: export NVM_DIR="$HOME/.nvm" [ -s "/usr/local/opt/nvm/nvm.sh" ] && \. "/usr/local/opt/nvm/nvm.sh" # This loads nvm [ -s "/usr/local/opt/nvm/etc/bash_completion.d/nvm" ] && \. "/usr/local/opt/nvm/etc/bash_completion.d/nvm" # This loads nvm bash_completion 按esc,输入wq 保存退出
最后一步之行:
source ~/.zshrc
查看是否安装好了
nvm -v 显示: 0.40.1 安装好啦!!!
下一篇:《python网站运行搭建》