LoginSignup
0
0

More than 5 years have passed since last update.

[メモ]Node.jsのインストール手順

Posted at

Nodeの環境を準備していきます。

  • node.jsのバージョン管理ツールの「nodebrew」の導入
  • Node/パッケージモジュール管理ツールのNPMをインストール

1.nodebrewのインストール

Homebrewを使ってインストールします

brew install nodebrew

nodebrewコマンドでインストールが正常になされている確認できます。

nodebrew
nodebrew 0.8.1

Usage:
    nodebrew help                         Show this message
    nodebrew install <version>            Download and install a <version> (compile from source)
    nodebrew install-binary <version>     Download and install a <version> (binary file)
    nodebrew uninstall <version>          Uninstall a version
    nodebrew use <version>                Use <version>
    nodebrew list                         List installed versions
    nodebrew ls                           Alias for `list`
    nodebrew ls-remote                    List remote versions
    nodebrew ls-all                       List remote and installed versions
    nodebrew alias <key> <version>        Set alias to version
    nodebrew unalias <key>                Remove alias
    nodebrew clean <version> | all        Remove source file
    nodebrew selfupdate                   Update nodebrew
    nodebrew migrate-package <version>    Install global NPM packages contained in <version> to current version
    nodebrew exec <version> -- <command>  Execute <command> specified <version>

Example:
    # install from binary
    nodebrew install-binary v0.10.22

    # use a specific version number
    nodebrew use v0.10.22

    # io.js
    nodebrew install-binary io@v1.0.0
    nodebrew use io@v1.0.0

次に、~/.bashrcに以下を追加します。

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

追加が完了したら再読み込みして設定を反映します

source .bashrc

以上でnodebrewのインストールが完了しました。
続けてnodebrewでnode.jsのインストールを進めていきます。

2.node.jsのインストール

以下のコマンドでnode.jsの安定版をバイナリからインストール可能です。 installコマンドのほうだと時間がかかってしまうようです。

nodebrew install-binary stable

もし過去にnodebrewを使ってnode.jsをインストールしていた場合は、以下でインストール済みのバージョンを確認し、最新版を使うように設定することが可能です。

nodebrew ls
v0.11.16
v0.12.3
v0.12.4

最新版のv0.12.4を使いたいので以下となります。

nodebrew use v0.12.4

node.jsをインストールすると、パッケージ管理ツールのNPM(Node Package Manager)も同時にインストールされているはずです。

npm -l

とすると使用方法を確認できます



Usage: npm <command>

where <command> is one of:

    access      npm access public [<package>]
                npm access restricted [<package>]
--

ここまででnode.jsの準備が完了しました。

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