參考 https://medium.com/@mahcloud/mac-brew-node-10-upgrade-55d3e910eebb
1. 使用 brew 或者 n 管理 Node.js
On Mac
$ brew install n
On Linux, n-install allows installation directly from GitHub; for instance: (參考https://github.com/tj/n)
$ curl -L https://git.io/n-install | bash
=== n successfully installed.
The active Node.js version is: v12.16.1
Run `n -h` for help.
To update n later, run `n-update`.
To uninstall, run `n-uninstall`.
IMPORTANT: OPEN A NEW TERMINAL TAB/WINDOW or run `. ~/.bashrc`
before using n and Node.js.
===
$ . ~/.bashrc
$ n
2. 安裝或更新Node.js過程中可能遇到網絡、依賴等問題,以下可以解決問題
brew uninstall --ignore-dependencies --force node
brew uninstall --ignore-dependencies --force icu4c
brew install icu4c
brew unlink icu4c && brew link icu4c --force
brew install node
如果安裝完成後沒有鏈接到 /usr/local/bin/node ,可以手動鏈接
ln -s /usr/local/Cellar/node/13.11.0/bin/node /usr/local/bin/node