Skip to content

How To Install Node.js on MacOS

How do I install Node.js and NPM on MacOS system? The easy way to install/upgrade Node.js and NPM on MacOS systems. How to install Node.js on MacOS.

Category
macOS
Covers
Node.js, npm
On this page

Node.js is a powerful JavaScript runtime environment that allows you to execute JavaScript on the server-side. It is widely used to develop scalable web applications, command-line tools, and more. In this article, we will go through the process of installing Node.js on a macOS system.

Prerequisites

  • A Mac computer running macOS.
  • Administrative access to install software.

Installation Methods

There are several ways to install Node.js on macOS:

  1. Homebrew (Recommended)
  2. Node.js official installer
  3. NVM (Node Version Manager)

Let’s delve into each method:

Method 1: Homebrew

If you’re not familiar with Homebrew, it’s a package manager for macOS that simplifies the installation of software on Apple’s macOS operating system.

Steps:

  1. Install Homebrew (if not installed):
    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" 
    
  2. Update Homebrew:
    brew update 
    
  3. Install Node.js:
    brew install node 
    
  4. Verify Installation: To make sure Node.js was installed correctly, type:
    node -v 
    

    And for npm:

    npm -v 
    

Method 2: Node.js Official Installer

Node.js provides an official macOS installer that you can download and use.

Steps:

  1. Download Installer: Go to the official Node.js download page and download the macOS installer.
  2. Run Installer: Open the downloaded .pkg file and follow the installation instructions.
  3. Verify Installation: Open Terminal and type:
    node -v 
    

    And for npm:

    npm -v 
    

Method 3: NVM (Node Version Manager)

NVM is a script-based command-line tool that allows you to manage multiple versions of Node.js and associated tools.

Steps:

  1. Install NVM: To install NVM, you can use the following curl command:
    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash 
    

    (Note: The version number (v0.39.5 in this case) may change. Refer to the official NVM GitHub repository to get the latest version.)

  2. Install Node.js: After NVM is installed, you can install the latest Node.js version with:
    nvm install node 
    
  3. Switch Between Node Versions (optional): If you have multiple versions of Node.js installed, you can switch between them using:
    nvm use [version_number] 
    
  4. Verify Installation: To check the currently active version of Node.js, type:
    node -v 
    

    And for npm:

    npm -v 
    

Conclusion

There you have it! Three different methods to install Node.js on macOS. Depending on your specific needs or preferences, you can choose the one that’s right for you. Homebrew is recommended for general users due to its simplicity and ease of use. On the other hand, if you’re a developer who needs to juggle between different Node.js versions, NVM can be invaluable. The official installer is straightforward and is provided directly from the Node.js team. Whatever method you choose, you’ll be well on your way to building great JavaScript applications!

Rahul

Rahul Kumar is the founder and chief editor of TecAdmin.net. A Red Hat Certified Engineer (RHCE), he has worked in IT since 2009, with hands-on experience in Linux system administration, DevOps, web hosting, cloud platforms and automation. He started TecAdmin in 2013 to share practical, step-by-step guides, and leads its editorial work with one aim: making technical learning clear and useful for sysadmins, developers and beginners alike.

1 Comment

Leave a Reply

Your email address will not be published. Required fields are marked *


Back to top