brew详解:http://stackoverflow.com/questions/3987683/homebrew-install-specific-version-of-formula
最终我使用的命令:
1. 查看当前node版本
$ ls -l `which node`
lrwxr-xr-x 1 cyper admin 30 Jul 26 12:09 /usr/local/bin/node -> ../Cellar/node/0.12.7/bin/node
2. 查看已经安装过的所有版本
$ ls /usr/local/Cellar/node*
/usr/local/Cellar/node:
0.12.7
/usr/local/Cellar/node010:
0.10.40
3。查看某个node标签的详细信息
$ brew info node
或brew info node010
4。如果从第二步的结果中可以找到0.10.40的node,则可以直接switch过去
$ brew switch node010 0.10.40
4. 如果先前没有安装0.10的版本,可以查看所有可用的版本,从这里可以找到homebrew/versions/node010,这正是我后面安装所需要的版本。
$brew search node
5. 直接安装会提示必须先unlink现有的符号连接
$ brew unlink node
6. unlink后再安装就开始下载并安装了。
$ brew install homebrew/versions/node010
==> Installing node010 from homebrew/homebrew-versions
==> Downloading https://homebrew.bintray.com/bottles-versions/node010-0.10.40.yosemite.bottle.tar.gz
7. 查看node
$ node -v
0.10.40
###版本切换测试
$ brew unlink node010 Unlinking /usr/local/Cellar/node010/0.10.40... 6 symlinks removed $ brew switch node 0.12.7 Cleaning /usr/local/Cellar/node/0.12.7 6 links created for /usr/local/Cellar/node/0.12.7 $ brew unlink node Unlinking /usr/local/Cellar/node/0.12.7... 7 symlinks removed $ brew switch node 0.10.40 Error: node does not have a version "0.10.40" in the Cellar. Versions available: 0.12.7 $ brew switch node010 0.10.40 Cleaning /usr/local/Cellar/node010/0.10.40 5 links created for /usr/local/Cellar/node010/0.10.40 $ node -v v0.10.40