English follows Japanese.
まだ書きかけです。(サーチエンジンキャッシュと事故防止用に保存公開しながら連々書き足していきます。)
node.js をマルチバージョンで切り替えて使いたい場合、インストール、管理方法は何がいいのか?
という問いにしばらく悩まされていたわけだが。。
# ちなみに私のメイン環境は MacOSX (Snow Leopard, Lion), サブが Windows (7, XP) です、サーバーが CentOS とか色々。それと、書き上げるのに時間がかかりそうなので、自分的結論から先に書いておくと、npm はソース(git or curl | sh)からインストール、nodeは n にインストールすることにしました。
もちろん答えは人によって違うし、何も考えなければ、最近の node.js は npm も含まれているし、Win, Mac 用は OS ネイティブのインストーラーになったし、単体インストールで終わりなのかもしれない。
でも私は仕事柄複数のバージョンを使わなくてはならない場面が多いし、ググってみると割りと同じ問題で悩んでいる人も多いようだ。
で、とりあえず (Mac 中心に) ざっと調べてみると、単一バージョン管理向けのものも、複数バージョン管理向けのものも含めて以下のようなものがあるようだった。
- MacPorts (マカーのみ )
- HomeBrew (マカーのみ)
- nvm (nvm for Windows はドザー向け, shell)
- nave
- n
- nodeenv (python)
- nodebrew (perl)
さて、どれがいいのか?
取り急ぎ、ざっと調べてみた範囲で分かったことを共有したい。
まずは考えるべきポイント。
- npm のインストールと管理方法
node.js だけでは何もできないと言って良い。npm も入れることになるが、複数のバージョンの node に対して個別に npm がインストールされるか、共有されるかは後の運用に大きな影響を及ぼす。
- 環境依存性
Win, Mac, Linux で可能なら同じ物を使いたい。また、使っている Shell (bash, zsh, cmd, PowerShell など) の制約や依存の少ないほうがいい。
- マルチユーザーアカウントで使える(使いやすいもの)
最近は PC も一人一台だし、あまり気にしない人も増えてきたが、チーム開発サーバーを管理していたり、 個人でも root とマイアカウント両方で作業する場合などは考慮した方がいいだろう。ホームディレクトリ以下にインストールするタイプはマルチユーザー向けではないよね。
Mac Ports
- Language Written: Tcl
- Install npm per version?: no
- Can switch multiple versions?: no?
yes
- Check installations:
port installed nodejs
- Check available versions:
port search nodejs
- Install:
sudo port install nodejs # default installation
port variants nodejs # to check variants
sudo port install nodejs +python26 # specify the variant using python26
- Switch:
sudo port select --list nodejs
sudo port select --set nodejs nodejs-0.6.10
HomeBrew
- Language Written: Ruby
- Install npm per version?: no (npm 自体インストールしない)
- Can switch multiple versions?: yes (but not very easy nor powerful)
- Check installations:
- Check available versions:
- Install:
- sudo port install nodejs # default installation
- port variants nodejs # to check variants
- sudo port install nodejs +python26 # specify the variant using python26
- Switch:
- sudo port select –list nodejs
- sudo port select –set nodejs nodejs-0.6.10
nvm
nave
n
nodeenv
nodebrew
参考:
How to install/manage multiple versions of nodejs?
This article is still a draft verision, and the content is subject to change.
That is the question I have been struggling with these days.
I am a Mac user and using Windows, Linux too, but the systems I use most is Mac, so let me share gathered info from the net with you mostly from MacOS user perspective.
There are quite a few variations of software which allows you to install and manage nodejs.
- MacPorts (MacOS)
- HomeBrew (MacOS)
- nvm (shell, there is nvm for Windows too)
- nave
- n
- nodeenv (python)
- nodebrew (perl)
So what is the best s/w to use for what? Well, the answer must be different among people and their needs, but I guess there are a couple of things to consider before you choose one of them.
- npm installation and management
node.js alone can not do many things, so you must need to install npm too. The question here is that npm is installed per node version, or shared among all the installed versions. This affect the way how you manage node packages in the daily use.
- Platform dependency
For those users who need to work with multiple OSes like me, it may be better to use the same one on all the platforms. The same can be said about the Shell dependency. it is better it to work with multiple shells(bash, zsh, cmd, PowerShell, etc)
- Allow multiple user accounts to use the same installation(s).
This is important for those users who share the same development server among dev team members, or one who may need to switch user account on the same system. The s/w which installs node under user’s home directory is not good from this perspective.
- Language Written: Tcl
- Install npm per version?: no
- Can switch multiple versions?: no?
yes
- Check installations:
port installed nodejs
- Check available versions:
port search nodejs
- Install:
sudo port install nodejs # default installation
port variants nodejs # to check variants
sudo port install nodejs +python26 # specify the variant using python26
- Switch:
sudo port select --list nodejs
sudo port select --set nodejs nodejs-0.6.10
HomeBrew
- Language Written: Ruby
- Install npm per version?: no (npm 自体インストールしない)
- Can switch multiple versions?: yes (but not very easy nor powerful)
- Check installations:
- Check available versions:
- Install:
- sudo port install nodejs # default installation
- port variants nodejs # to check variants
- sudo port install nodejs +python26 # specify the variant using python26
- Switch:
- sudo port select –list nodejs
- sudo port select –set nodejs nodejs-0.6.10
nvm
nave
n
nodeenv
nodebrew
Reference