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 Info:

Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.

Follow him on: X

You can also reach out to him via e-mail: rakesh@code2care.org

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