Quick Overview:
To aid the macOS users in installing the NPM, the blog provides all three main approaches. The first approach deals with the traditional way of downloading and installing the NPM. The second and third approaches provide a brief overview of using Homebrew and NVM for NPM installation. As a result, you will be equipped with all the primary ways to install the npm Mac version.

Install NPM on Mac

With the emergence of JavaScript and the need for a high-performance application, NodeJS has become a popular development technology. To utilize Node JS for your project, you need to install the NPM, as it provides the required environment for developers to use Node JS.

You must have seen numerous tutorials for NPM installation on Windows. But, here, we are going to understand the procedure to install NPM on Mac.

Why Install NPM on Mac?

NPM is the main package manager that is used to install the Node JS on a macOS machine. It also helps manage and install other packages for your software development project. If you have to develop an application with Node JS, then NPM must be available on your system.

In addition, NPM also helps developers in reducing their efforts. It can be used to share reusable software components with other development teams and professionals.

Requirements To Install NPM on Mac

Before dividing the process into how to install npm mac, ensure that your system fulfills the following criteria.

  • An internet connection will be used as multiple files will be downloaded.
  • A minimum of 4GB RAM
  • 256 GB Storage (ROM)
  • Updated macOS version

Method 1: Install NPM on Mac using the Traditional Way

The traditional way is considered the most convenient for developers and professionals of all levels. The entire process is GUI-based and similar to installing NPM on the Windows operating system. Even if someone has not used macOS before, they can easily execute the install the NPM Mac version.

Step 1: From the official website of Node JS, download the installation package for macOS.

install-npm-on-mac-1

Step 2: Open the location where the package is saved and run it using the double-click.

Further, an installation window will appear on your screen. Follow the procedure with its default settings and complete all parts of the NPM configuration. Lastly, click on “Install Software Summary” and wait for its completion.

As a final result, you will see a snippet below.

install-npm-on-mac-2

Step 3: Now, validate that the NodeJS and NPM are installed on your system. To do so, open the command line and run the below command. It will return the installed version number.

Command: node -v

Step 4: However, if a newer version is available, you can update yours by executing the following command in CLI. It will update the NPM and NodeJS versions simultaneously.

Command: $ sudo npm install npm –global // Update the npm CLI client

Step 5: Once you have the required NPM version installed, configure the NODE HOME variable. By utilizing the same CLI, run one more command.

Command: export PATH=/usr/local/git/bin:/usr/local/bin:$PATH  

However, if you have different profiles and want to set variables for all users. Then, you should use the two CLI commands listed below to add configuration to the “.bash_profile” file.

Command: echo ‘export PATH=/usr/local/bin:$PATH’ >> ~/.bash_profile  Command: source ~/.bashrc

Method 2: Install NPM Mac Version with Homebrew

Homebrew is one of the most used and reliable package managers MacOS professionals consider. It helps to install and use the stuff that a user needs.

The main reason for using Homebrew is that it doesn’t interfere with system binaries and libraries. All the installations are made in a separate directory known as “/usr/local.”

Further, to install Homebrew on your macOS system, run the command:

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

Following its installation, undergo the NPM installation process as listed.

Step 1: A single command is enough with Homebrew to download and initiate the NPM and NodeJS installation.

Open the CLI of the macOS machine and execute the command: brew install node

NPM will be installed in a minimal amount of time.

Step 2: To verify the available version of NPM on your system, use the below commands.

To check the NPM version: npm -v

To check NodeJS version: node -v

Step 3: By default, Homebrew installs the latest version. However, if the latest version is not installed, use the following macOS CLI commands.

To update NPM: brew update

To update NodeJS: brew upgrade node

Method 3: NVM Approach to Install NPM Mac

On a macOS system, you can use NVM or Node Version Manager to install NPM. The procedure is quite streamlined and completed using only the CLI.

Step 1: Download and install the NVM by using any of the following approaches.

Approach #1: Installation through cURL

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

Approach #2: Installation through wget

wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash

Step 2: Run “nvm -version” to verify its installation on your system. The CLI will display the NVM version as the output.  

In addition, it’s recommended that the command be added to the .bash_profile or .zshrc file. It ensures that all configured terminals have the same configurations. To do so, use the below command.

Command: echo ‘export PATH=/usr/local/bin:$PATH’ >> ~/.bash_profile

To finalize the changes, run: source ~/.bashrc

Step 3: Run the MVM command to install the NodeJS and NPM.

Command: nvm install node

In addition, to install a specific NPM version, use the below command.

Command: nvm install v12.15.0

Here, “12.15.0” is the version number, which can be modified per requirements.

Step 4: To verify the NPM installation through NVM, utilize the command below.

Command: node -version

To list all node versions: nvm is

Concluding Up

Installing NPM on macOS is an easy and quick procedure. There are three main methods available to install NPM on a Mac machine. The first method is downloading the package and installing it through GUI. The second method is completed through the Homebrew package manager. The third method uses NVM. You can use any of the installation approaches, as their end result is quite similar, that is, you get the NPM and Node JS on your system.

Parag Mehta

Verified Expert in Software & Web App Engineering

Parag Mehta, the CEO and Founder of Positiwise Software Pvt Ltd has extensive knowledge of the development niche. He is implementing custom strategies to craft highly-appealing and robust applications for its clients and supporting employees to grow and ace the tasks. He is a consistent learner and always provides the best-in-quality solutions, accelerating productivity.

Related Posts