LoginSignup
3
4

More than 5 years have passed since last update.

MacにNode.jsの開発環境を構築する

Last updated at Posted at 2018-01-10

Node.jsの管理はnodebrewが楽なのでnodebrewを使いましょう。
nodebrewはhomebrewでインストールします。

Homebrewのインストール

homebrewのインストール(公式)

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

nodebrewのインストール

:one: インストール可能なバージョンを確認する

$ nodebrew ls-remote

:two: インストール

今回はv8を入れたいと思います。
以下で8の最新を入れます

$ nodebrew install-binary v8
Installed successfully

:three: インストールできてるか確認

$ nodebrew ls
v8.11.2

current: none

:three: 使うバージョンを指定する

$ nodebrew use v8
use v8.11.2

:two: インストールが終わったら環境変数の設定をする。

$ vi .bash_profile

 .bash_profileに以下を書き込む。

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

  .bash_profile再読み込み

$ source .bash_profile

Node.jsのインストール

環境変数を設定したらnodebrewが使えるようになるので、早速Node.jsをインストールしましょう。

バージョンは安定版(stable)のインストールがおすすめです。

$ nodebrew install-binary stable

nodebrew useで、使うバージョンを切り替えます。

$ nodebrew use stable
3
4
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
3
4