LoginSignup
26
30

More than 5 years have passed since last update.

Nodenv環境を用意する

Last updated at Posted at 2017-09-17

良記事がすでにありますが(http://qiita.com/1000ch/items/41ea7caffe8c42c5211c など)、公式のReadmeをもとにコマンドの投入順序を少し整理しています。
記事執筆にあたってMacOSX 10.11.6で確認していますが、Bash利用のLinux系OSであれば同様の手順でいけると思います。

Nodenvのインストール

nodenv の実行ファイル群をホームディレクトリにコピーする

git clone git://github.com/nodenv/nodenv.git ~/.nodenv

node環境構築用プラグインのnode-buildをnodenv環境のプラグインフォルダにコピーする

git clone git://github.com/nodenv/node-build.git ~/.nodenv/plugins/node-build

nodenvへパスを通す設定を.bash_profileへ追加
(対象ファイルや書き方は環境に応じて要変更)

echo 'export PATH="$HOME/.nodenv/bin:$PATH"' >> ~/.bash_profile

nodenvの利用開始コマンドを.bash_profileへ追加

echo 'eval "$(nodenv init -)"' >> ~/.bash_profile

追加内容を適用する
(公式はシェルの再起動としている)

source ~/.bash_profile

作業フォルダへ個別のNode環境を構築

インストール可能なNodeのバージョンを確認

nodenv install --list

インストールしたいバージョンのNodeを取得

nodenv install <listで確認したバージョン>

取得したバージョンのNodeをカレントディレクトリに適用

nodenv local <installで取得したバージョン>

nodeのバージョンを確認

node -v

インストールしたバージョンが表示されればOK

26
30
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
26
30