摘要
转载请注明出处:http://my.oschina.net/uniquejava/blog/491030
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
或者用
➜ ~ $ brew switch node fuck
Error: node does not have a version "fuck" in the Cellar.
Versions available: 0.12.7, 5.3.0
➜ ~ $
然后就可以用
brew unlink node && brew switch node 0.12.7这样的命令直接切过去了!!!!
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
8. 如果是全新安装:
先执行brew search node
然后执行brew install homebrew/versions/node010
9. brew设置http代理:
执行man brew再搜索proxy就可以找到解决办法
tools can download via a proxy. It's common for these tools to read proxy parameters from environment variables.
For the majority of cases setting http_proxy is enough. You can set this in your shell profile, or you can use it before a brew command:
http_proxy=http://<host>:<port> brew install foo
If your proxy requires authentication:
http_proxy=http://<user>:<password>@<host>:<port> brew install foo