Help us understand the problem. What is going on with this article?

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

More than 5 years have passed since last update.

1. nvmインストール


$ cd ~
$ git clone git:// .nvm
$ . .nvm/


[[ -s (自分のホームディレクトリ)/.nvm/ ]] && . (自分のホームディレクトリ)/.nvm/
nvm use default
export NODE_PATH=$npm_dir

一旦ターミナルを抜けるとか、source ~/.bash_profileとかして、./bash_profileの更新を反映させる。


Node Version Manager

    nvm help                    Show this message
    nvm install [-s] <version>  Download and install a <version>
    nvm uninstall <version>     Uninstall a version
    nvm use <version>           Modify PATH to use <version>
    nvm run <version> [<args>]  Run <version> with <args> as arguments
    nvm ls                      List installed versions
    nvm ls <version>            List versions matching a given description
    nvm ls-remote               List remote versions available for install
    nvm deactivate              Undo effects of NVM on current shell
    nvm alias [<pattern>]       Show all aliases beginning with <pattern>
    nvm alias <name> <version>  Set an alias named <name> pointing to <version>
    nvm unalias <name>          Deletes the alias named <name>
    nvm copy-packages <version> Install global NPM packages contained in <version> to current version

    nvm install v0.4.12         Install a specific version number
    nvm use 0.2                 Use the latest available 0.2.x release
    nvm run 0.4.12 myApp.js     Run myApp.js using node v0.4.12
    nvm alias default 0.4       Auto use the latest installed v0.4.x version

2. Node.jsをインストール


$ nvm ls-remote


$ nvm install v0.10.12


$ npm install

3. Node.jsの実行


$ nvm use v0.10.12


  "name": "hoge",
  "version": "0.0.1",
  "description": "hoge!",
  "main": "server.js",
  "scripts": {
    "test": "mocha test/**/*.test.js",
    "start": "node server.js"

下記コマンドで server.jsが実行される。

$ npm start


$ node server.js

4. nvm use **コマンドを実行するのが面倒な場合

$ nvm alias default v0.10.12


妻と娘と“限定”の文字と朝に弱いRuby, PHP, Perl, Java, Javascriptが喋れる流浪のプログラマ。
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away