LoginSignup

This article is a Private article. Only a writer and users who know the URL can access it.
Please change open range to public in publish setting if you want to share this article with other users.

More than 5 years have passed since last update.

node.jsを入れるならnodebrewで管理しよう!

Posted at

nodebrewってなに?

nodebrewは、node.jsをバージョンごとに管理してくれるツールです。
プロジェクトごとにnode.jsのバージョンが違ったりしても、コマンド一発でバージョン変更が出来ちゃうって便利っすね!
perlbrewやrbenvみたいなものだと思ってください。

事前準備

まずnode.jsがインストールされているか確認してください。

$ node -v

何も出てこなければ、次の作業へ!
既にnode.jsをインストール済みの方は、以下を参考にnode.jsをアンインストールしてください。

nodebrewのインストール

以下のコマンド実行してください(公式サイトを参考にしてます!)

$ curl -L git.io/nodebrew | perl - setup
...
========================================
Add path:

export PATH=$HOME/.nodebrew/current/bin:$PATH
========================================

nodebrewは~/.nodebrewにインストールされます!なんで、
export PATH=$HOME/.nodebrew/current/bin:$PATH は、.bashrcや.zshrcに書いてください。
それが終わったら再読み込み!

$ source ~/.bashrc
$ nodebrew -v

これでnodebrewのバージョンが出てくれば完了です!

node.jsをインストール

はじめにインストールできるnode.jsのバージョンを確認します。

$ nodebrew ls-remote

バージョン一覧が出てきます。
現時点の最新はv0.10.25でした!インストールします。

$ nodebrew install-binary v0.10.25

インストールが終わったら、確認しましょう。

$ nodebrew ls 
v0.10.25

current: none

インストールできてますね!
currentは現在利用しているバージョンです。あとは使いたいバージョンを指定してあげれば終わりです。

$ nodebrew use v0.10.25
$ node -v
v0.10.25

終わりっす!簡単でしたねw

参考

0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up