LoginSignup
7
5

More than 5 years have passed since last update.

nvmをinstall時に他の場所に導入する方法

Last updated at Posted at 2014-07-15

nvmには便利なinstall scriptが用意されています。

curl https://raw.githubusercontent.com/creationix/nvm/v0.10.0/install.sh | bash

しかし、これを実行してしまうと、~/.nvm に導入されてしまいます。
これでも良いのですが、foreverなど、sudo必須なモジュールを動かすのには適しません。

そこで、install場所を/opt/nvmに導入すれば普段はsudo必須ではなく、また/etc/sudoersを編集すればsudo foreverなどといった事ができるようになります。

How To

shell
mkdir /opt
cd /opt
export NVM_DIR=/opt/nvm
curl https://raw.githubusercontent.com/creationix/nvm/v0.10.0/install.sh | bash

これで/opt/nvmに導入されるので、後は

.*shrc
if [[ -s /opt/nvm/nvm.sh ]] ;
    then source /opt/nvm/nvm.sh ;
fi

.*shrcに追加すれば導入完了です。
Shellを再起動すればnvmコマンドが使用可能になっているかと思います。

後は

shell
nvm ls-remote # node.jsのサイトからバージョン一覧を取得
nvm install v0.10.29
node -v
npm -v

以上で導入完了です。

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