post-image

Install ndenv


Node.jsバージョン管理「ndenv」をインストールする。これで、異なるバージョンのアプリケーションの開発が同時で行いやすくなる。 でも、本当はホストOSを汚したくないから、Dockerでやる方がいいのかもしれない。

Node.jsバージョン管理「ndenv」

インストール

リポジトリからインストールする(採用)

$ git clone https://github.com/riywo/ndenv ~/.ndenv
$ echo 'export PATH="$HOME/.ndenv/bin:$PATH"' >> ~/.bash_profile
$ echo 'eval "$(ndenv init -)"' >> ~/.bash_profile
$ exec $SHELL -l
$ git clone https://github.com/riywo/node-build.git $(ndenv root)/plugins/node-build

Homebrewでインストールする

$ brew install ndenv

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

$ ndenv install v10.16.0
$ ndenv rehash

バージョンを確認する

$ node -v
ndenv: node: command not found

The `node' command exists in these Node versions:
  v10.16.0

インストールされているバージョンの一覧を表示する

$ ndenv versions
  v10.12.0
  v10.16.0

バージョン管理は2種類

  • プロジェクト(フォルダ)単位で管理する場合は ndenv local
  • グローバル(PC全体)で設定する場合は ndenv global

グローバル

$ node -v
ndenv: node: command not found

The `node' command exists in these Node versions:
  v10.12.0
  v10.16.0

$ ndenv global v10.16.0
$ node -v
v10.16.0

ローカル

$ cd sample-v10-12-0/
$ ndenv local v10.12.0
$ node -v
v10.12.0
$ cd ..
$ node -v
v10.16.0
  • sample-v10-12-0はv10.12.0で動作する
  • それ以外のフォルダはv10.16.0(global)で動作する

Back to blog

あなたのひらめきをかたちに

どうやって作るのか想像がつかなければ、一緒に作り上げましょう.

お話をうかがさせてください