0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

MacにNode.jsをインストールする

Posted at

Webシステム開発において、色々なサーバサイドJavaScript実行環境が登場してきていますが、その中でもNode.jsは根強い人気があります。

MacにNode.jsをインストールするために、nodebrewを利用してインストールする方法をまとめました。

nodebrewをインストールする

Node.jsのバージョンを切り替えやすくするため、まずはnodebrewをインストールします。

$ curl -L git.io/nodebrew | perl - setup

~/.bash_profileに環境変数を追加します。

$ echo 'export PATH=$HOME/.nodebrew/current/bin:$PATH' >> ~/.bash_profile

設定を反映させるために、以下のコマンドを実行するか、ターミナルを再起動します。

$ source ~/.bash_profile

Node.jsをインストールする

nodebrewを使ってNode.jsをインストールします。

$ nodebrew install-binary stable #安定版の場合
$ nodebrew install-binary latest #最新版の場合
$ nodebrew install-binary v14.7.0 #バージョン指定する場合

以下のコマンドでインストールされているか確認します。
初めてのインストールの場合、まだ利用するように設定していないため、「current: none」になっていると思います。

$ nodebrew ls
v14.7.0

current: none

「nodebrew use」で利用したいバージョンを指定します。

$ nodebrew use v14.7.0

再度バージョンを確認してみると、以下のように「current」にバージョンが表示されているはずです。

$ nodebrew ls
v14.7.0

current: v14.7.0

以上で設定は完了です。

0
1
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
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?