Guide to Installing Node.js on Windows, Linux, or MacOS
Getting Node.js installed will always be the first step in getting started with building Node.js applications.
In this article, we'll walk you through downloading Node.js.
There are three sections: Windows, Linux, and macOS. Choose the one that matches your operating system.
Once completed, you'll be ready to start building Node.js applications!
Table of Contents
Windows
For Windows, we will install Node.js directly from the Node.js website.
Let's get started!
Install Node.js
Follow this link to the download page on the Node.js website and click the Windows Installer button.
This will start a download of the .msi
file.
When that is complete, click on the downloaded file to start the Node.js Setup Wizard. You will be given a series of prompts as you work through the setup wizard.
When you are finished, open a command prompt and execute the following command:
node --version
You should see an output similar to this (you may see a different version number based on which one you installed):
v18.13.0
NPM (Node.js Package Manager) should have been automatically bundled with your Node.js installation. But you can double-check it with this command:
npm --version
You should see an output similar to this (you may see a different version number based on which one you installed):
v9.3.1
You now have Node.js installed and it's ready for you to use!
Linux
We'll be using the Node Version Manager (Nvm
). And compared to other Node.js installation methods, it has the easiest ways to have multiple versions of Node.js without adding much extra complexity. There will be times when applications need different versions of Node.js to work, so having the flexibility to change that is important and will save you a lot of time.
Before going through these steps, open a new terminal (CTRL
+ALT
+T
) and navigate to the home directory of your machine:
cd ~
Install/Verify System Packages
First, let's update the system packages on your machine:
apt-get update
When that finishes, run the following command to install the build-essential
package if you don't already have it:
apt-get install build-essential
Install Nvm (Node Version Manager)
Now we are ready to install the nvm
package. Use one of the two (curl
or wget
) commands below to run the nvm
bash script.
At the time of publication, NVM v0.39.3
was the most recent version available. Make sure you check the NVM Github project page to get the latest version and replace the yellow text in the commands below.
curl
command:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
Or use the wget
command:
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
The bash
script clones the nvm
repository to ~/.nvm
and adds the source line to your profile (~/.bash_profile
, ~/.zshrc
, ~/.profile
, or ~/.bashrc
).
Reload the Shell
After running the above command, you will receive an output message similar to the following in your terminal:
...
=> Close and reopen your terminal to start using nvm or run the following to use it now:
...
You can reload the shell by running:
source ~/.bashrc
Or simply open a new Terminal window/tab.
Verify the Installation
To verify that nvm
was installed correctly, use this command:
nvm --version
You should see an output with the version of nvm
you downloaded.
Now let's install the latest Node.js stable release (replace v18.13.0
with the version you wish to install):
nvm install v18.13.0
You now have Node.js installed and it's ready for you to use!
macOS
We'll use the Node Version Manager (Nvm
). And compared to other Node.js installation methods, it has the easiest ways to have multiple versions of Node.js without adding much extra complexity. There will be times when applications need different versions of Node.js to work, so having the flexibility to change that is important and will save you a lot of time.
Before going through these steps, open a new terminal window.
To open it, either open your Applications folder, then open Utilities and double-click on Terminal, or press Command - spacebar to launch Spotlight and type "Terminal"
, then double-click the search result.
Install Nvm (Node Version Manager)
Now we are ready to install the nvm
package. Use one of the two (curl
or wget
) commands below to run the nvm
bash script.
At the time of publication, NVM v0.39.3
was the most recent version available. Make sure you check the NVM Github project page to get the latest version and replace the version shown in the commands below.
curl
command:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
Or use the wget
command:
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
The bash
script clones the nvm
repository to ~/.nvm
and adds the source line to your profile (~/.bash_profile
, ~/.zshrc
, ~/.profile
, or ~/.bashrc
).
Reload the Shell
After running the above command, you will receive an output message similar to the following in your terminal:
...
=> Close and reopen your terminal to start using nvm or run the following to use it now:
...
You can reload the shell by running:
source ~/.bashrc
Or simply open a new Terminal window/tab.
Verify the Installation
To verify that nvm
was installed correctly, use this command:
nvm --version
You should see an output with the version of nvm
you downloaded.
Now let's install the latest Node.js stable release (replace v18.13.0
with the version you wish to install):
nvm install v18.13.0
You now have Node.js installed and you are ready to start building!