This guide shows several methods to install and test Node.js and NPM on Windows.
- A user account with administrator access (or the ability to download and install software).
- Access to the command prompt.
- A text editor or IDE to run code and test Node.js.
Install Node.js and NPM on Windows via Node.js Installer
If you prefer using the GUI to install programs, Node.js has a downloadable installer on their official website. Follow the steps below to install Node.js and NPM on Windows via the installer.
Step 1: Download Node.js Installer
In a web browser, navigate to the Node.js Downloads page. Click the Windows Installer button to download the latest stable version with long-term support (LTS). The installer also includes the NPM package manager.
The file is saved in the Downloads folder by default.
Other versions of Node.js and NPM are available, so choose the appropriate one for your system and use case. Use the top tabs to switch from the LTS to the current version to test the newest features. If you are new to Node.js or don't need a specific version, choose LTS since it is tested and stable.
Step 2: Install Node.js and NPM
After downloading the installer, follow the steps below:
1. Launch the installer by double-clicking the downloaded file.
2. The Node.js Setup Wizard starts with the welcome screen.
Click Next to proceed.
4. Review the end-user license agreement and click the checkbox to accept the terms and conditions.
Click Next to continue.
5. The installer asks to choose the installation location.
Leave the default location for a standard installation and click Next to proceed.
6. Select components to include or remove from the installation. The default options install Node.js, NPM, corepack, online documentation shortcuts, and add the programs to PATH.
Customize the setup or click Next to accept the default values.
7. The following section shows the total required space for the installation and the available space on disk.
Click OK to proceed. Select a different disk or install fewer features if the installation does not allow proceeding.
8. Choose whether to install additional dependencies for compiling native modules. Some NPM modules compile from C/C++ and require additional tools to function correctly (Python, Visual Studio Build Tools, and Chocolatey).
If you use such modules, select the checkbox and click Next. The selection of this option starts an installation script after the Node.js installation is complete.
For a simple installation, skip this step and click Next to proceed.
7. Click the Install button to start the installation.
8. The installer prompts for administrator confirmation to make changes to the device.
Enter the administrator password if prompted and click Yes to continue.
9. The installation takes some time. When it is complete, the final screen shows a success message.
Click Finish to complete the installation and close the installer.
Note: If you selected to install native tools in step 8, closing the installer automatically starts a PowerShell script to install the listed tools.
Step 3: Verify Installation
To verify Node.js installed successfully, run the following command in a command prompt or PowerShell:
The command shows the Node.js version installed on your system. Use the following command to check for NPM:
Note: If NPM is not recognized or properly installed, command prompt displays the following error message: npm: command not found. Check if NPM is added to path, or if there are multiple versions installed on the system.
Install Node.js and NPM on Windows via Chocolatey
Chocolatey is a Windows package manager. It can be used to install programs such as Node.js with NPM. Follow the steps below to install Node.js and NPM using Chocolatey.
Note: Chocolatey is not available on Windows by default. If you need to install it, follow our guide to install Chocolatey on Windows.
Step 1: Install Node.js and NPM
To run the installation command, do the following:
1. Open the command prompt as an administrator.
2. Run the following command to install Node.js and NPM:
choco install nodejs
When prompted to run the installation script, press y and Enter to continue the installation. Wait for the installation to complete before proceeding.
3. Reset environment variables to add Node.js and NPM to PATH. Use the following command:
The command resets the environment variables, which enables running both programs from the terminal.
Step 2: Verify Node.js and NPM installation
To verify that Node.js is installed correctly, run the following command in a new command prompt session:
Check the NPM installation with:
Both commands display the program version.
Test Node.js Installation
1. Open a text editor or IDE.
2. Add the following code to the file:
The code is a simple program that prints "Hello, world!" to the console.
3. Save the script with a .js extension.
4. Run the program from an IDE to see the results. Alternatively, navigate to the directory where the file is located and use the following command:
The command prints the message to the console, indicating that the Node.js installation works successfully.
Next, see the differences between Yarn and NPM, two different Node.js package managers.