Node.js – the recommended way to install Node.js, nvm and npm on MacOS X


I am trying to use Homebrew as much as possible. What's the recommended way to install Node.js, nvm and npm on MacOS X?

Best Answer

  1. Using homebrew install nvm:

    brew update
    brew install nvm
    source $(brew --prefix nvm)/

    Add the last command to the .profile, .bashrc or .zshrc file to not run it again on every terminal start. So for example to add it to the .profile run:

    echo "source $(brew --prefix nvm)/" >> ~/.profile

    If you have trouble with installing nvm using brew you can install it manually (see here)

  2. Using nvm install node or iojs (you can install any version you want):

    nvm install 0.10
    # or
    nvm install iojs-1.2.0
  3. npm is shipping with node (or iojs), so it will be available after installing node (or iojs). You may want to upgrade it to the latest version:

    $ npm install -g npm@latest

    UPD Previous version was npm update -g npm. Thanks to @Metallica for pointing to the correct way (look at the comment bellow).

  4. Using npm install ionic:

    npm install -g ionic
  5. What about ngCordova: you can install it using npm or bower. I don't know what variant is more fit for you, it depends on the package manager you want to use for the client side. So I'll describe them both:

    1. Using npm: Go to your project folder and install ng-cordova in it:

      npm install --save ng-cordova
    2. Using bower: Install bower:

       npm install -g bower

      And then go to your project folder and install ngCordova in it:

       bower install --save ngCordova


  1. Some commands may require superuser privilege
  2. Short variant of npm install some_module is npm i some_module