1. Using homebrew install nvm:

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

    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)/nvm.sh" >> ~/.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 (see the comment below).

  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
      

PS

  1. Some commands may require superuser privilege
  2. Short variant of npm install some_module is npm i some_module
Answer from alexpods on Stack Overflow
Top answer
1 of 11
307
  1. Using homebrew install nvm:

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

    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)/nvm.sh" >> ~/.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 (see the comment below).

  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
      

PS

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

Use nvm to install Node.js, not Homebrew

In most of the answers, the recommended way to install nvm is to use Homebrew.

Don't do this.

On nvm's Github Readme is clearly says:

Homebrew installation is not supported. If you have issues with homebrew-installed nvm, please brew uninstall it, and install it using the instructions below, before filing an issue.

Use the following method instead

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash

The script clones the nvm repository to ~/.nvm and adds the source line to your profile (~/.bash_profile, ~/.zshrc, ~/.profile, or ~/.bashrc).

And then use nvm to install node. For example to install latest LTS version do:

nvm install 16

Clean and hassle free. It will set this as your default Node.js version as well so you should be all set.

🌐
The Surly Dev
surly.dev › articles › how-to-setup-node-on-mac
How to Setup Node on Mac Without Homebrew
This post shows you how to setup Node.js on a Mac without using Homebrew. ... A specific version of Node.js. In this case, the latest LTS (Long Term Support) version. ... nvm (Node Version Manager) is a version manager for Node.js, designed to manage multiple versions of Node.js on a single machine. curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.2/install.sh | bash
🌐
Newline
newline.co › @Adele › how-to-install-nodejs-and-npm-on-macos--22782681
How to install Node.js and npm on macOS | newline
June 25, 2020 - In this post, we'll be looking at three different ways to install Node.js and its package manager, Node Package Manager, on macOS. We will discuss how to install Node.js using mac-native package installer, homebrew, a 3rd party installer, Node Version Manager and how to hop between different ...
🌐
pawelgrzybek
pawelgrzybek.com › install-nodejs-installer-vs-homebrew-vs-nvm
Install Node.js — installer vs. Homebrew vs. NVM | pawelgrzybek.com
I published “Fix privileges and never again use sudo with npm” with some solutions for this issue, but you better check “Resolving EACCES permissions errors when installing packages globally” on official documentation or follow this article. “Homebrew — the best friend of the macOS ...
🌐
Pinegrow Community
forum.pinegrow.com › general › random
What is the Best, better Way to Install Node.js, NPM on a mac? - Random - Pinegrow Community Forum
Hello! as it says above. I’m pretty sure this could either be ignored, or start a flame war. …or I’ll be totally blown away by everyone agreeing on one way! But Macports… https://www.macports.org/ Homebrew… … the stand alone Installer, made by the devs themselves?
Published   February 14, 2021
🌐
Treehouse
treehouse.github.io › installation-guides › mac › node-mac.html
Installing Node.js® and NPM on Mac
NPM is a “package manager” that makes installing Node “packages” fast and easy. A package, also called a module, is just a code library that extends Node by adding useful features. For example, the “request” module simplifies the process of making HTTP requests so you can easily get web resources from other sites. ... Although there is Mac installer program on the Node website, we recommend using Homebrew to install and update Node.
🌐
Medium
medium.com › @littlecodingthings › how-to-install-npm-on-macos-039b77e37244
How to Install npm on MacOS. Installing Node.js and NPM (Node… | by Little Coding Things | Medium
1 week ago - How to Install npm on MacOS Installing Node.js and npm (Node Package Manager) on your Mac is super simple. With these tools, you can manage Javascript packages, create powerful web applications, and …
Find elsewhere
🌐
GitHub
gist.github.com › DanHerbert › 9520689
Instructions on how to fix npm if you've installed Node through Homebrew on Mac OS X or Linuxbrew · GitHub
Homebrew maintainers have fixed things and the options mentioned don't exist and won't work. I still believe it is better to manually install npm separately since having a generic package manager maintain another package manager is a bad idea, but the instructions below don't explain how to do that.
🌐
GitHub
gist.github.com › rcugut › c7abd2a425bb65da3c61d8341cd4b02d
Install node & npm on Mac OS X with Homebrew · GitHub
# run the following commands # ... latest 'node' # - if you don't use `yarn` (yarnpkg.com), prefer LTS 'node@6' brew install node --without-npm # install yarn (see yarnpkg.com for more info) brew install yarn # follow up with: ...
🌐
Reddit
reddit.com › r/webdev › nvm or homebrew for node install
r/webdev on Reddit: Nvm or homebrew for Node install
April 12, 2023 -

I come across this decision every time I get a new Mac laptop/computer.

I like nvm, node version manager, because it allows me to install multiple versions of node/npm in case I need to switch within different versions.

Does homebrew offer the same? Are there other install recommendations for Mac?

The need to switch node versions does come up when asked to work on another project that is “stuck” on an older version of node due to outdated packages that no one wants to maintain but is still used in the project.

April 12, 2023 Update Thanks for all the great recommendations and insight. I decided to use fnm for my own preference at this time, but all alternatives seem great in their own way. Here is a great article from Honeybadger comparing many node environment managers: https://www.honeybadger.io/blog/node-environment-managers

🌐
Reddit
reddit.com › r/node › have node installed on mac, but not npm, suggestions? is there a way to install npm separately?
r/node on Reddit: have node installed on mac, but not npm, suggestions? is there a way to install npm separately?
June 25, 2019 -

I installed node in the past with the help of someone irrc, but npm is not installed when I checked:

Mac-Users-Apple-Computer:~ z$ npm -v
internal/modules/cjs/loader.js:583
    throw err;
    ^

Error: Cannot find module '../lib/utils/unsupported.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
    at Function.Module._load (internal/modules/cjs/loader.js:507:25)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:22:18)
    at /usr/local/lib/node_modules/npm/bin/npm-cli.js:19:21
    at Object.<anonymous> (/usr/local/lib/node_modules/npm/bin/npm-cli.js:153:3)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)

I guess I wanted to try a clean install of node.js with npm, but when I tried to remove node, I got this, a yarn dependency, something I also had someone help install at some point for something(can tell, I'm a newbie to this):

Mac-Users-Apple-Computer:~ z$ brew uninstall node
Error: Refusing to uninstall /usr/local/Cellar/node/11.11.0
because it is required by yarn, which is currently installed.
You can override this and force removal with:
  brew uninstall --ignore-dependencies node

Should I override / remove node and do an install from scratch? Or can I install npm separately(don't know that that would be advised). it seems brew install node should install node and npm based on a reference link further down below, I just don't see npm on my system right now and don't recall how i had node installed the first time.

here are some references I was looking at:

https://treehouse.github.io/installation-guides/mac/node-mac.html

https://stackoverflow.com/questions/11177954/how-do-i-completely-uninstall-node-js-and-reinstall-from-beginning-mac-os-x

🌐
Quora
quora.com › What-is-the-difference-between-Homebrew-and-NPM-macOS-X
What is the difference between Homebrew and NPM (macOS X)? - Quora
Answer: Thanks for your A2A P. Withayasakpunt! Homebrew is a Unix-like package manager that should have been included in the original version of MAC OS X but was not. NPM is a set of web dev libraries for Node, JS, and the like within Homebrew. Now one can install NPM without Homebrew but then y...
🌐
TWM
twm.me › posts › best-practice-for-installing-node-js-for-developers-on-mac-os
Best Way To Install Node.js on Mac Os For Developers [2025]
The other way to install Node.js is to do it directly using Homebrew, instead of using Homebrew to install NVM just for it to install Node.js, as in the previous section. This could also be better if you are new to Node.js development. That is if you find that there are too many versions and you just want something to get you started.
🌐
Radixweb
radixweb.com › blog › installing-npm-and-nodejs-on-windows-and-mac
How to Install NPM and Node.js on Windows and Mac Devices?
September 17, 2025 - Learn what is NPM, how to install Node.js and NPM on Mac and Windows, Node.js installation with Homebrew and NVM and few points to consider while installing Node.js and NPM.
🌐
Reddit
reddit.com › r/learnjavascript › can't install npm on mac
r/learnjavascript on Reddit: can't install npm on mac
September 14, 2020 -

Hi everyone,

I'm building a website where I would like to apply this effect. So I read that I need to install npm in order to download its dependencies. The thing is that when I execute the command npm install I get this error: -bash: npm: command not found I searched for this error trying to figuring out what's wrong but I could't find a solution. I'm currently using Mac High Sierra operating system.

Can you help me understand how to install npm correctly?

thanks

🌐
Brainstorm
brainstorm.it › snippets › how-install-nodejs-and-npm-mac
How to Install Node.js and NPM on a Mac - Brainstorm
# install a specific NPM version, # with the `-g` / `--global` flag to replace the previously installed version npm install -g npm@4
🌐
Quora
quora.com › What-is-the-best-way-to-install-Node-JS-and-npm-on-OS-X
What is the best way to install Node JS and npm on OS X? - Quora
Answer (1 of 2): I somehow don't like installing through the .pkg files given on Node's website. Well, I'm personally against installing any .pkg files at all if I can help it, so if you ask me my suggestions will be either: 1. Install via Homebrew. This options gives you version upgrades for ea...
🌐
Positiwise
positiwise.com › home › install npm on mac | easiest way possible
Install npm on Mac | Easiest Way Possible - Positiwise
July 4, 2024 - Install npm on Mac with this easy step-by-step guide. Follow our simple instructions to set up Node.js and npm on your macOS system.