➜ /Users/fatli > brew install node@8
Updating Homebrew...
==> Downloading https://homebrew.bintray.com/bottles/node@8-8.11.3.sierra.bottle
######################################################################## 100.0%
==> Pouring node@8-8.11.3.sierra.bottle.tar.gz
==> Caveats
This formula is keg-only, which means it was not symlinked into /usr/local,
because this is an alternate version of another formula.
If you need to have this software first in your PATH run:
echo 'export PATH="/usr/local/opt/node@8/bin:$PATH"' >> ~/.zshrc
For compilers to find this software you may need to set:
LDFLAGS: -L/usr/local/opt/node@8/lib
CPPFLAGS: -I/usr/local/opt/node@8/include
==> Summary
🍺 /usr/local/Cellar/node@8/8.11.3: 4,430 files, 47.2MB
开发环境:
参考:
一、安装 node
使用 Homebrew 安装 node 8.11.3 (截止 2018.06 LTS 版本为 8.11.3 ):
创建软链接到 /usr/local/bin :
二、卸载
三、brew install node 和 brew install node@8
使用
brew install node
(不指定 node 版本号)命令安装 node ,文件分布:使用
brew install node@8
(指定 node 版本号)命令安装 node ,文件分布:brew install node
(不指定 node 版本号)命令安装 node ,将安装最新版的 node ,并且会自动在 /usr/local/bin 目录下创建“替身“(即软链接)。brew install node@8
(指定 node 版本号)命令安装 node ,不会自动在 /usr/local/bin 目录下创建“替身“(即软链接),需要使用ln -s
命令在 /usr/local/bin 目录下创建软链接。(brew search node
查看可指定安装的版本)brew uninstall node
(不指定版本号)命令卸载 node 软件包后,需要手动到 /usr/local/bin 目录下删除相应到 npm 、 npx 替身 ( node 替身会被自动删除)。brew uninstall node@8
(指定版本号)命令安装的 node 软件包后,使用ln -s
命令创建在 /usr/local/bin 目录下的 node 、 npm 、 npx 替身(软链接)会自动随着brew uninstall node@8
卸载而被删除,不需要手动去删除。附:更新 npm
参考:
实例:不更新 node,单独更新 npm 5.6.0 → 6.14.4(此时时间为 2020.04.07):