How to Install Node.js and NPM on Windows and Mac?

Install Node.js and NPM

JavaScript has become a go-to language in the software development industry. The front-end developers aim to create feature-rich UI with JavaScript development and engage with back-end web services using AJAX. Since JavaScript offers non-blocking nature, web developers who work on the server-side have shifted their paradigm to JavaScript.

In fact, choosing JavaScript development services as your first option will surely bring plenty of opportunities to master a single language while still developing “full-stack” web applications. And the vital key to this server-side JavaScript revolution is NodeJs.

Now, let’s understand what Node.js is.

NodeJs is a cross-platform environment that runs and executes JavaScript codes outside the browser. It’s a version of Chrome’s V8 JavaScript runtime engine, allowing you to develop server-side JavaScript applications. It comes up with everything which is required to run a program written in JavaScript.

So, if you plan to install NodeJs and NPM in your system, we are here to guide you with detailed steps.

So, let’s get into the Node.js development guide of installation.

First, we will learn how to install NodeJs and NPM on Windows.

But do you know what NPM is?

NPM

The NPM – Node Package Manager is the default package manager for NodeJs. Basically, NodeJs is a JavaScript runtime environment, allowing developers to develop the scalable application in a given time.

NPM allows open-source web developers to share and borrow packages for app development. Also, it works as a command-line utility for the application for installing packages in the project, dependency management, and even version management.

Components of NPM

1) Website: You can find packages from the official NPM website for your project. Also, you can create and set up profiles to manage and access all types of packages.

2) Command Line Interface (CLI): To interface with NPM packages and repositories, the CLI runs from your computer’s terminal.

3) Registry: It has a huge database of JavaScript projects and meta-data. Thus, it allows you to use any supported NPM registry. Also, you can utilize someone else’s registry as per their terms of use.

Prerequisites

Here’s what you need to go ahead with NodeJs and NPM.

Hardware Requirements

  • RAM 4GB
  • CPU Intel Core i3TM i3 HQ CPU @2.50 GHz
  • ROM 256 GB

Software Requirement

  • Chocolatey

How to Install Node.js and NPM on Windows?

Since we have decided to create an application using Node.Js, first of all, you have to install Node.Js on your Windows system.

Here, we are going to explain the installation process step-by-step. So, let’s start with the first step now.

Step 1: Download the Installer

Download the Windows Installer from NodeJs official website. Make sure you have downloaded the latest version of NodeJs. It includes the NPM package manager.

Here, we are choosing the 64-bit version of the Node.js installer.

Install Node.js 64-bit Version

The LTS (Long-term Support) version is highly recommended for you. After the download of the installer package, install it with a double-click on it.

Now .msi file will be downloaded to your browser. Choose the desired location for that.

Step 2: Install Node.js and NPM

Install NPM and Node.js

After choosing the path, double-click to install .msi binary files to initiate the installation process. Then give access to run the application.

You will get a welcome message on your screen and click the “Next” button. The installation process will start.

  • Choose the desired path where you want to install Node.js.
Choose Path to Install Node.js
  • By clicking on the Next button, you will get a custom page setup on the screen. Make sure you choose npm package manager, not the default of Node.js runtime. This way, we can install Node and NPM simultaneously.

You should have 143MB of space to install Node.js and npm features.

The following features will be installed by default:

  • Node.js runtime
  • Npm package manager
  • Online documentation shortcuts
  • Add to Path
Select Node.js Features to install
  • Bang! The setup is ready to install Node and NPM. Let’s click on the Install button so hard!
Final Step of Node.js Installation

Step 3: Check Node.js and NPM Version

  • If you have a doubt whether you have installed everything correctly or not, let’s verify it with “Command Prompt”.

Check Node.js and NPM Version

Command Prompt window will appear on the screen.

To confirm Node installation, type node -v command.

To confirm NPM installation, type npm -v command.

And you don’t need to worry if you see different numbers than mine as Node and NPM are updated frequently.

Frequent Update of Node and NPM

In my case, the version of node.js is v14.15.3 and npm is 6.14.9.

How to Install Node.js and NPM on Mac?

Now, if you are using a macOS, let’s understand the process of Node.js and NPM installation.

Install Node Using .pkg Installer

Well, it’s a similar process as Windows. Here, Node provides a .pkg installer for Mac. Besides, we can also download from its official website.

Install Node Using .pkg Installer

Step 1: Download the .pkg Installer

Click on the “macOS Installer” option to download the .pkg installer. Make sure you download it to your desired location.

Step 2: Run Node.js Installer

Now, your installer is ready to run. However, it will not take your much time. So, let’s explain in detail here.

Introduction > Continue
License > Select Continue > Agree
Installation Type > Install > Authenticate with your Mac to allow the Installation > Install Software
Summary > Close

Run Node.js Installer

Step 3: Verify Node.js Installation

To verify whether you have properly installed Node.js in your macOS, run the following command in your terminal:

node -v
node -v // The command we ran - tests the version of Node.js that's currently installed
v12.13.0 // The version of Node.js that's installed. It can be some other version.

Step 4: Update Your NPM Version

Node.js doesn’t automatically update the version of npm.

Write a given command and your npm version will be updated.

$ sudo npm install npm –global // Update the `npm` CLI client

Tadda! Node.js is there on your Mac system. Interesting, right? Let’s explore it further.

Set NODE HOME in Environment Variable

Now, run the given command in your terminal for Mac or Linux systems. This ensures that the NODE path is set in the PATH variable.

export PATH=/usr/local/git/bin:/usr/local/bin:$PATH

Here, /usr/local/bin is the default path where Node will be installed.

Actually, it’s advisable to write this command in .bash_profile or .zshrc. However, it depends on which shell you are using so that these path export stay on your system and nobody can recognize them from all the terminal instances.

Let’s run the given command to add the details in .bash_profile file permanently.

echo ‘export PATH=/usr/local/bin:$PATH’ >>~/.bash_profile

Run the given command to make it available to all users on the system.

source ~/.bashrc

How to Install Node Using “Homebrew”?

Homebrew is an open-source and free software package management system, simplifying the installation process on macOS and Linux. It installs packages to their directory and their files into /usr/local.

Here, we can use Homebrew to install Node.js. After this installation, let’s move to the next step.

Step 1: Install Node.js and NPM

It’s very easy to install Node.js and NPM using Homebrew. It lets you download, unpack and install Node and NPM on your device.

Run the given command in your terminal.

brew install node

Some files will be downloaded. So, let’s install them.

Step 2: Verify Node.js and NPM Installation

Same as the windows system, you just have to type the below-given command and run it in your terminal.

For Node: node -v

For NPM: npm -v

Homebrew will update the version of Node and NPM you have installed. Make sure that your Homebrew has the latest version of the Node package.

If not, then run the given command to update the Homebrew.

brew update

Run given the command to update version of node:

brew upgrade node

It will update Node and NPM to the latest version.

How to Install Node Using NVM – Node Version Manager?

Being a professional NodeJs developer, I have got many requests asking to install multiple versions of Node.js on their devices. Yes, it is possible with NVM – Node Version Manager.

Let’s follow the given steps and install Node.

Step 1: Download NVM with Install Script

Now, you have two options to install NVM.

With cURL:

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash // Installation using cURL

With wget:

wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash // Installation using Wget

Now NVM will be downloaded and installed.

Step 2: Verify NVM Installation

You can verify NVM with the given command:

nvm –version

The command will show something like (not necessarily exact):

0.33.0 # The current version of nvm – yours may differ!

Actually, it’s advisable to write this command in .bash_profile or .zshrc. However, it depends on which shell you are using so that these path export stay on your system and nobody can recognize them from all the terminal instances.

Let’s run the given command to add the details in the .bash_profile file permanently.

echo ‘export PATH=/usr/local/bin:$PATH’ >>~/.bash_profile

Run the given command to make it available to all users on the system.

source ~/.bashrc

Step 3: Install the Latest Node Version Using NVM

Run the given command to install the latest version of Node.js.

nvm install node

Moreover, you can select all the available Node versions if you want to install a specific version.

Let’s run the given command:

nvm ls-remote // This will list down all the available Node version

nvm install v12.15.0 // This will install Node 12.15.0

Now, let’s check the installation of different Node framework versions and which specific versions are used with the given command.

nvm ls // This will list all the Node versions installed on your machine.

nvm use v12.15.0 // This will set the Node version to 12.15.0

Also, verify the existing version with the given command:

node –version

It will show “12.15.0”, as it is used in the above commands.

Done!

Now you are all set with your Node installation and can further develop the Node application.

Key Pointers to Consider

  • You can install Node.js on your Windows system using the .msi installer from the official website of Node.
  • You can install Node.js on your macOS using the .pkg installer from the official website of Node.
  • In addition, we can also install Node on macOS using the package manager Homebrew.
  • NVM offers an easy way to install and maintain different versions of Node on the same device.

Want to install latest NodeJS version for your business need?

Conclusion

Let me tell you that there are various ways to install Node.js frameworks and NPM in your given system. Here, we have given you the easiest way for the installation on your Windows and macOS. That’s all you need to get started with Node.js. However, you are free to choose a system of your preference.

So, if you have any doubt and are looking to develop a NodeJs application for your specific operating system, contact the prominent Node.Js development company – Radixweb. Our experts will be happy to assist you.

Don't Forget to share this post!

Jaydeep Patadiya is a senior business development manager at Radixweb and always has the answer to- what's on the mind of the customers? In an industry that is fundamentally changing, he helps customers make the right decisions by connecting the right dots and adopt new technologies. Beyond work, he prepares for upcoming marathon races.