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

-

Facing issues? Have Questions? Post them here! I am happy to answer!


Author: Rakesh
Author Info:

Rakesh is a seasoned developer with over 10 years of experience in web and app development, and a deep knowledge of operating systems. Author of insightful How-To articles for Code2care.

Follow him on: X

Copyright © Code2care 2023 | Privacy Policy | About Us | Contact Us | Sitemap