In this tutorial, we'll learn how to install Node.js and NPM on Windows, macOS and Linux, in this step-by-step guide. By the end of it, you will have a valid installation of Node and NPM.
What is Node?
What is NPM?
NPM (Node Package Manager) is the package manager for Node. It allows you to install and manage packages for Node. NPM is a big reason why Node is so popular today. There are so many packages that you can easily download that you can use to build your own applications.
When you install Node, NPM is automatically installed for you, so you can get started with it right away.
With that being said, let's get started by installing Node.
How to install Node on Windows
To download Node, you can use the Node download page and download the Windows Installer (.msi) file. This installer contains everything you need to install, update, or modify Node on your computer.
Make sure you select the correct version for your Windows operating system, as there are 32-bit and 64-bit versions available.
Once the installer has downloaded, run it to begin the installation process. Accept the terms of the License Agreement to continue.
Now set the path that Node will be installed to. It is recommended to leave it as the default.
Continue the installation process by clicking the "Next" button, and install Node. You should see this if you finished the installation process:
You have now installed Node on Windows.
How to install Node on Mac
To install Node on Mac, go to the Node download page and download the macOS installer (.pkg) file.
This installer contains everything you need to install, update, or modify Node on your Mac.
Once downloaded, run the installer to begin the installation process.
Agree to the License Agreement to continue.
You can change the installation location but it is recommended to leave it as the default. Proceed and hit install.
Finally, you should see the confirmation that the installation was successful. Click close to finish the installation process.
You should now have Node installed on your Mac.
How to install Node on Linux
Linux has many different ways to install Node. This guide will show you how to install Node on Ubuntu using the easiest possible way.
Node provides a binary distribution page that contains the latest version of Node for each distribution.
Since we are using Ubuntu, let's follow the instructions for Ubuntu.
To start, you will need
curl installed to download the Node binary. If you don't already have
curl you can install it easily:
sudo apt-get install curl
Now that you have
curl installed, let's download the latest Node binary for Ubuntu.
curl -fsSL https://deb.nodesource.com/setup_17.x | sudo -E bash -
This will prepare your system to install Node by downloading the libraries required. After this command finishes, you can now install Node on your Linux system.
sudo apt-get install -y nodejs
If all goes well, you should have a working Node installation on your Linux system.
Verify Node installation
To verify that Node is installed correctly, you can check the version of Node by running the following command:
This will return the version of Node that you have installed. If it does not, you will see an error message.
Verify NPM installation
Like with Node, you can also verify that NPM is installed correctly by checking the version that is on your system:
This command will return either the version of NPM that you have installed or an error message if it is not installed.