How to Install npm using Mac Terminal

If you want to install npm the package manager for NodeJS you can make use of the brew package manager.


Step 1: Make sure Brew is Installed

    The first thing we do is check if HomeBrew is installed on the Mac using the command, brew --version

    Check if Brew is installed on Mac

    If you see an error - "zsh: command not found: brew" then run the below command in your Terminal to install brew first.

    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Step 2: Installing npm

    Now we are good to install npm, simply run the below command in Mac Terminal.

    brew install node

    Once the installation is done, you can check if was installed correctly using the below commands.

    macOS % node -v
    v20.4.0
    
    macOS % npm -v
    9.7.2

Read More:

https://formulae.brew.sh/formula/node

Comments & Discussion

Facing issues? Have questions? Post them here! We're happy to help!