Introduction
Node.js and NPM are two of the most popular tools used for developing web applications. Node.js is a JavaScript runtime environment that allows you to run JavaScript code on the server side, while NPM is a package manager that helps you manage and install packages for your Node.js applications. Installing Node.js and NPM on Mac is a relatively straightforward process, and in this guide, we will walk you through the steps.
How to Install Node.js and NPM on Mac
1. Download the Node.js installer from the Node.js website.
2. Run the installer and follow the on-screen instructions.
3. Open a terminal window and type node -v to confirm that Node.js is installed.
4. Type npm -v to confirm that NPM is installed.
5. You can now use Node.js and NPM to develop applications.
Introduction
Node.js is a popular back-end JavaScript runtime used for creating web servers and scalable network apps. The environment supports server-side scripting – producing dynamic content for web pages before they are served to the user.
NPM is a package manager for JavaScript and the default package manager for Node.js. As such, NPM is installed alongside Node.js as a recommended feature.
This tutorial will show you how to install Node.js and NPM on Mac using the Homebrew package manager.
Prerequisites
- Access to the terminal
- Administrative level privileges
Note: Node.js has a PKG installer for macOS available on its website. However, installing with Homebrew is the recommended approach.
Install Homebrew
1. To install Homebrew on macOS, browse to Homebrew’s official website and copy the link displayed on the page.
Note: Do not copy the command from the screenshot since it may change in the future. Always visit the website for the up-to-date command.
2. Open the terminal and paste the command. Type the sudo password when prompted. Lastly, confirm that you want to install Homebrew by pressing Return.
Install Node.js and NPM on Mac
Note: For other operating systems, refer to our tutorials on installing Node.js and NPM on Windows, Ubuntu, CentOS, and Debian.
1. Type the following command to install Node.js and NPM:
brew install node
Homebrew downloads and installs the dependencies.
2. When the installation finishes, confirm that you successfully installed Node.js by checking its version:
node -v
The system displays the Node.js version as the output of the command.
3. Next, check the installed version of NPM by typing:
npm -v
The NPM version number is displayed.
Update Node.js and NPM on Mac
1. Before you proceed with upgrading the Node.js installation, update Homebrew’s repositories by typing:
brew update
2. When the update completes, type the following command:
brew upgrade node
The output in the example shows that the newest version of Node.js is already installed on the system.
Uninstall Node.js and NPM on Mac
1. Uninstall both Node.js and NPM with the brew uninstall
command:
brew uninstall node
2. Remove all the unused dependencies with:
brew autoremove
This command removes the packages that brew uninstall
did not remove.
Conclusion
After reading this tutorial, you should know how to use Homebrew to install Node.js and NPM on macOS. If you wish to find out more about the MEAN stack, which features Node.js, read LAMP vs. MEAN: Which is Better?
How to Install Node.js and NPM on Mac
Installing Node.js and NPM on Mac is a relatively straightforward process. Node.js is a JavaScript runtime environment that allows you to run JavaScript code outside of a browser. NPM is a package manager for Node.js packages, or modules if you like. In this tutorial, we will show you how to install Node.js and NPM on a Mac.
Step 1: Download Node.js
The first step is to download the Node.js installer from the Node.js website. Go to https://nodejs.org/en/ and click on the “Download” button. This will download the Node.js installer to your computer.
Step 2: Install Node.js
Once the download is complete, double-click on the .pkg file to start the installation process. Follow the on-screen instructions to complete the installation. Once the installation is complete, you should be able to open a terminal window and type “node -v” to check the version of Node.js that is installed.
Step 3: Install NPM
NPM is installed with Node.js, so you don’t need to install it separately. To check the version of NPM that is installed, open a terminal window and type “npm -v”. This will output the version of NPM that is installed.
Conclusion
In this tutorial, we have shown you how to install Node.js and NPM on a Mac. Installing Node.js and NPM is a relatively straightforward process, and once it is complete you can start using them to develop applications.