LoginSignup
17
16

More than 5 years have passed since last update.

公式サイト

インストール

公式サイトの指示に従ってインストール。

$ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.32.1/install.sh | bash
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 10250  100 10250    0     0   4049      0  0:00:02  0:00:02 --:--:--  4049
=> Downloading nvm from git to '/Users/sotoiwa/.nvm'
=> Cloning into '/Users/sotoiwa/.nvm'...
remote: Counting objects: 5891, done.
remote: Compressing objects: 100% (156/156), done.
remote: Total 5891 (delta 20), reused 0 (delta 0), pack-reused 5735
Receiving objects: 100% (5891/5891), 1.66 MiB | 895.00 KiB/s, done.
Resolving deltas: 100% (3550/3550), done.
Checking connectivity... done.
* (HEAD detached at v0.32.1)
  master
=> Compressing and cleaning up git repository
Counting objects: 5891, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (5856/5856), done.
Writing objects: 100% (5891/5891), done.
Total 5891 (delta 3888), reused 1894 (delta 0)

=> Profile not found. Tried  (as defined in $PROFILE), ~/.bashrc, ~/.bash_profile, ~/.zshrc, and ~/.profile.
=> Create one of them and run this script again
=> Create it (touch ) and run this script again
   OR
=> Append the following lines to the correct file yourself:

export NVM_DIR="/Users/sotoiwa/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"  # This loads nvm
=> Close and reopen your terminal to start using nvm or run the following to use it now:

export NVM_DIR="/Users/sotoiwa/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"  # This loads nvm
$ 

インストール時に.bash_profileが存在しないと必要な記述を追加してくれないので、以下の内容で作成する。あるいはtouch ~/.bash_profileしてファイルをつくってインストールをやり直してもよい。

.bash_profile
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm

設定反映のために一旦シェルを抜けて入り直す。あるいはsource ~/.bash_profileする。

$ nvm --version
0.32.1
$ 

インストール可能なバージョンをリストする。

$ nvm ls-remote
        v0.1.14
        v0.1.15
        v0.1.16
        v0.1.17
        v0.1.18
(中略)
         v6.7.0
         v6.8.0
         v6.8.1
         v6.9.0   (LTS: Boron)
         v6.9.1   (Latest LTS: Boron)
         v7.0.0
$ 

今回はv4.3.1をインストールする。

$ nvm install v4.3.1
######################################################################## 100.0%
Computing checksum with shasum -a 256
Checksums matched!
Now using node v4.3.1 (npm v2.14.12)
Creating default alias: default -> v4.3.1
$ 
$ nvm ls
->       v4.3.1
default -> v4.3.1
node -> stable (-> v4.3.1) (default)
stable -> 4.3 (-> v4.3.1) (default)
iojs -> N/A (default)
lts/* -> lts/boron (-> N/A)
lts/argon -> v4.6.1 (-> N/A)
lts/boron -> v6.9.1 (-> N/A)
$ 
$ node --version
v4.3.1
$ 

参考にしたリンク

Macにnvm + Node.jsをインストールする

17
16
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
17
16