nvm (Node Version Manager)
nvm allows you to quickly install and use different versions of node via the command line.
https://github.com/nvm-sh/nvm
Install nvm
zsh
| curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash | 
一開始我安裝失敗,出現了跟這個一樣的狀況 HEAD detached at FETCH_HEAD #2486,最後跟 bestiptx99 說的方法成功了!只要按 q 鍵就可以了:「Just type in q and you’ll be able to come out of this non-interactable page and the rest of the installation gets done.」
Install node.js
Install the latest version of node.js
zsh
| nvm install node # "node" is an alias for the latest version | 
Install a particular version of node.js
zsh
| nvm install 12.18.0 | 
Set the default node version
Set the latest version as default
zsh
| nvm alias default stable | 
Set a specific version as default
zsh
| nvm alias default 12 | 
Quickly select node versioin
List out all the installed node version
zsh
| nvm ls | 
Select your desired node version
zsh
| nvm use 12 | 
zsh
| nvm use default | 

Uninstall nvm
不過裝了 nvm 後 generate hexo 超級慢,最後都是把 nvm 卸載了。
zsh
| nvm unload | 
Alternative
唯有繼續用這個方法來在多個 Node 版本之間切換吧
zsh
| brew search node | 
2023.06.08 updated: 以上 brew unlink link 方法也失效,用以下方法取代。
Alternative 2
方法來自: Hexo Deploy 失敗!? | mycTW Note - Software Management & Development
zsh
| nvm use 12 | 
Reference
- 在 MacOS 上如何管理多个 Node 版本 - 知乎 rainyjune
- How to Manage Multiple Node Versions in MacOS. (2021 Guide) | by Chamika Kasun | Medium

