How to Install Node.js on Mac, Windows, and Ubuntu Using Various Methods

Node.js is a powerful JavaScript runtime built on Chrome's V8 JavaScript engine. It's used for developing server-side and networking applications and is popular among developers for its efficiency and scalability. Here, we'll walk through the steps to install Node.js on different operating systems—Mac, Windows, and Ubuntu—using various methods such as direct download, package managers, and more.

4/29/20242 min read

black flat screen computer monitor
black flat screen computer monitor

How to Install Node.js on Mac, Windows, and Ubuntu Using Various Methods

Node.js is a powerful JavaScript runtime built on Chrome's V8 JavaScript engine. It's used for developing server-side and networking applications and is popular among developers for its efficiency and scalability. Here, we'll walk through the steps to install Node.js on different operating systems—Mac, Windows, and Ubuntu—using various methods such as direct download, package managers, and more.

Installing Node.js on Windows

Using the Node.js Installer

  1. Download the Installer: Visit the official Node.js website at nodejs.org and download the Windows Installer. Choose the LTS (Long Term Support) version for better stability.

  2. Run the Installer: Execute the downloaded .msi file and follow the installation wizard. Accept the license agreement, select the installation folder, and choose the components including NPM (Node Package Manager).

  3. Finish Installation: Follow the prompts to complete the installation. The installer will set up both Node.js and NPM.

Using Chocolatey (Package Manager)

  1. Install Chocolatey: First, you need to install Chocolatey on your Windows machine. Open an administrative Command Prompt and execute:

    Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))

  2. Install Node.js: After installing Chocolatey, type the following command to install Node.js:

    choco install nodejs-lts

  3. Verify Installation: Check that Node.js and NPM are installed correctly by running:

    node -v npm -v

Installing Node.js on Mac

Using the Node.js Installer

  1. Download the Installer: Navigate to nodejs.org and download the Mac Installer.

  2. Run the Installer: Open the downloaded .pkg file and follow the on-screen instructions to install Node.js and NPM.

Using Homebrew

  1. Install Homebrew: If you haven’t already installed Homebrew, open your terminal and run:

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

  2. Install Node.js: Once Homebrew is installed, type the following command to install Node.js:

    brew install node

  3. Verify Installation: Confirm that Node.js and NPM are installed by checking their versions:

    node -v npm -v

Installing Node.js on Ubuntu

Using the Package Manager

  1. Curl and NodeSource: First, add the Node.js PPA (Personal Package Archive) to your system using Curl and NodeSource. This ensures you get the latest version. Run:

    curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -

  2. Install Node.js: Now, install Node.js with:

    sudo apt-get install -y nodejs

  3. Verify Installation: Ensure Node.js and NPM are correctly installed by checking their versions:

    node -v npm -v

Using Snap

  1. Install Node.js Snap: Ubuntu supports snap packages, so you can also install Node.js via Snap:

    sudo snap install node --classic

  2. Verification: Check the installation by running:

    node -v npm -v

By following these steps, you can successfully install Node.js on Mac, Windows, or Ubuntu using a variety of methods. Whether through direct downloads, package managers, or other tools like Chocolatey and Homebrew, setting up Node.js is straightforward and opens up a world of development opportunities.