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 Hom...
Oops! This image does not follow our content guidelines. To continue publishing, please remove it or upload a different image.
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.
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.
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 -fsSLhttps://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 nodeNPM 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.
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.
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.
The Original Blog Published at Positiwise: https://positiwise.com/blog/install-npm-on-mac