LoginSignup
1
0

More than 3 years have passed since last update.

Node.js バージョン管理nodenvを使ってみる

Last updated at Posted at 2020-11-22

nodeのバージョン管理についてnというものを使ってみたが、
今回CentOs環境で別のnodenvを使ってみることにしました。

バージョン管理には他にも、
nodebrewがありますが、nodenvだとディレクトリごとにバージョンが変更できるみたいです
※ ついでに、win機はNodistというのがあるみたいです

※こちらの記事は、nodeが入っていることを前提にしてます。もしまだなら、インストールして置くようにしてしてください。またgitも入れておいてください

sudo yum install nodejs
sudo yum install npm

sudo yum install git-all #gitのインストール

anyenv インストール

anyenv」というツールを用いてインストールします

[vagrant@vagrant ~]$ git clone https://github.com/riywo/anyenv ~/.anyenv

パスを通して設定します

[vagrant@vagrant ~]$ echo 'export PATH="$HOME/.anyenv/bin:$PATH"' >> ~/.bash_profile
[vagrant@vagrant ~]$ echo 'eval "$(anyenv init -)"' >> ~/.bash_profile
[vagrant@vagrant ~]$ exec $SHELL -l

こちらを実行すると以下のようにでました。

ANYENV_DEFINITION_ROOT(/home/vagrant/.config/anyenv/anyenv-install) doesn't exist. You can initialize it by:
> anyenv install --init

指示通り初期をおこないます

anyenv install --init

nodenv インストール

anyenvを使用し、nodenvをインストールします

anyenv install nodenv
exec $SHELL -l

以下のコマンドを実行できたら成功です

nodenv

バージョンを切り替え

欲しいnode.jsのバージョンを以下のコマンドでインストールします

nodenv install 12.19.0

切り替えます

nodenv local 12.19.0

バージョン切り替え確認

今までインストールしている切り替え可能なバージョン一覧を確認

nodenv versions

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

nodeのインストール可能なバージョン確認する

nodenv install --list

参考URL
https://qiita.com/tonkotsuboy_com/items/5322d226b6783d25b5df

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