Time Server
Post by
Author Syukra

Published on Dec 14, 2024

Last updated on Apr 11, 2025

Estimated reading time: 5 minute

How to Install Nodejs on Various Platforms

Nodejs

Node.js is a JavaScript runtime environment built on Google Chrome’s V8 JavaScript engine. With Node.js, you can run JavaScript on the server side, making it possible to develop more efficient and modern web applications. In this article, we will cover the steps to install Node.js on various operating systems, including Windows, macOS, and Linux.

Preparing to Install Node.js

Before you start installing, make sure to choose the version of Node.js that suits your project’s needs:

  • LTS (Long-Term Support): The stable version recommended for most users and used in production environments.
  • Current: The latest version with the latest features, suitable for testing new features but may be less stable than LTS.

You can download the installer or use a package manager for installation.

How to Install Node.js on Windows

There are two main methods to install Node.js on Windows: using the installer from the official Node.js website or through the package manager Chocolatey.

a. Install Using Node.js Installer

  1. Download Installer: Go to the official Node.js website and select the LTS or Current version, then download the .msi installer file for Windows.

  2. Run Installer

  • Once the download is complete, open the .msi file. Follow the on-screen instructions to install Node.js.
  • You will be given the option to set the installation location and additional components, such as NPM (Node Package Manager). It is recommended to install NPM along with Node.js, as it is widely used in module management.
  1. Verify Installation
  • Once the installation is complete, open Command Prompt (CMD) and type the following commands to check the Node.js and NPM versions:
node -v
npm -v
  • If the installation is successful, you will see the installed Node.js and NPM versions.

b. Install Node.js Using Chocolatey

  1. Install Chocolatey
  • Chocolatey is a package manager for Windows. You can download and install Chocolatey by opening CMD as administrator and running the command:
@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
  1. Install Node.js with Chocolatey
  • Once Chocolatey is installed, you can install Node.js by running the command:
choco install nodejs
  • Once complete, check the installation with the node -v and npm -v commands.

3. How to Install Node.js on macOS

On macOS, there are a few different ways to do this, including using the direct installer or taking advantage of Homebrew, a popular package manager.

a. Install Using the Node.js Installer

  1. Download the Installer: Visit the Node.js website and download the .pkg installer file for macOS.

  2. Run the Installer

  • Once the file has downloaded, open it and follow the on-screen installation instructions.
  • Once the installation is complete, open Terminal to verify the installation with the command:
node -v
npm -v

b. Install Node.js with Homebrew

  1. Install Homebrew: If it is not already installed, download Homebrew by running the command in Terminal:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  1. Install Node.js with Homebrew
  • Once Homebrew is installed, install Node.js by running the command:
brew install node
  • Verify by typing node -v and npm -v in Terminal.

4. How to Install Node.js on Linux

On Linux, the method for installing Node.js depends on the distribution you are using, but the most common method is to use NodeSource or your distro’s package manager.

a. Install Using NodeSource

NodeSource provides a repository containing the latest version of Node.js. Here’s how to install it:

  1. Add NodeSource Repository: Run the following command to add the NodeSource repository according to the desired version.
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -

Or for the latest version:

curl -fsSL https://deb.nodesource.com/setup_current.x | sudo -E bash -
  1. Install Node.js:
sudo apt-get install -y nodejs
  • After the installation is complete, verify with node -v and npm -v.

b. Install Node.js with Distro Package Manager

On some Linux distributions, Node.js can be directly installed using a package manager such as apt (Debian/Ubuntu), dnf (Fedora), or yum (CentOS).

  • Debian/Ubuntu
sudo apt update
sudo apt install nodejs npm
  • Fedora
sudo dnf install nodejs
  • CentOS
sudo yum install nodejs

After installation, run node -v and npm -v to verify.

5. Verify Installation and Check Configuration

After the installation process is complete, you can do some additional steps to make sure everything went well.

  1. Check Node.js and NPM Version

Run the following command:

node -v
npm -v

If the Node.js and NPM versions appear on the screen, it means the installation was successful.

  1. Simple Node.js Test
  • Create a new file named app.js and add the following code:
console.log("Node.js has been successfully installed!");
  • Run the file with the command:
node app.js
  • If the message Node.js has been successfully installed! appears, Node.js is ready to use.

6. Conclusion

Installing Node.js is quite easy on various platforms, be it Windows, macOS, or Linux. With this guide, you can choose the appropriate method for your operating system and start developing Node.js applications. Once successfully installed, you can start developing server-side applications with efficient JavaScript. Also, don’t forget to keep Node.js updated to always get the latest features and security fixes.

With these steps, you now have a ready-to-use Node.js environment and can proceed to the application development stage.

That’s all the articles from Admin, hopefully useful… Thank you for stopping by…

Tag: #Programming#Tutorial
Share Article

Follow My Social Media