brew管理node的版本


摘要

nvm可以。brew怎么去切換不同的node版本

轉載請注明出處: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





免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM