This guide provides detailed steps for installing Node.js on Windows.
-
Go to the official Node.js website and click Download.
On the download page, select the Pre-built Installer tab. Select version v20.13.1 (LTS), operating system Windows, and architecture x64. Then, click the Download Node.js v20.13.1 button.
-
The download page offers several installation methods, as described in the table below.
NoteWe recommend selecting an LTS (Long-Term Support) version. LTS versions are more stable because they receive extended maintenance.
Installation method
Description
package manager
Uses the operating system's package manager (such as apt, yum, or brew) to install Node.js.
Pre-built Installer
A pre-built installer for a specific operating system, such as a
.msifile for Windows or a.pkgfile for macOS. These installers include the Node.js runtime, npm, and necessary dependencies.Pre-built Binaries
Pre-built Node.js executable files for various platforms. This method does not include a wizard; you must manually extract the files and configure environment variables.
Source Code
This method installs Node.js from its source code. You must extract, configure, and compile the source code using specific commands or scripts to complete the installation.
-
Double-click the downloaded installer and follow the wizard to complete the installation.
-
Press
Win+Rto open the Run dialog, typecmd, and then click OK to open Command Prompt. -
Enter
node -vandnpm -v. If the output is similar to the following, the installation was successful.C:\Users\xxx>node -v v20.13.1 C:\Users\xxx>npm -v 10.5.2 -
(Optional) Change the npm global module path and cache path.
After installing Node.js, you can use the npm package manager to install modules and libraries (collectively known as packages). By default, the global installation and cache paths are on the C: drive. Follow these steps to change these locations.
-
In your Node.js installation directory, create two new folders:
node_globalandnode_cache. -
Grant Write and Modify permissions for both folders. Right-click each folder and select Properties > Security. Select your user or group, click Edit, check the Allow boxes for Modify and Write, and then click OK.
-
In Command Prompt, run the following commands.
npm config set prefix "D:\ide\nodejs\node_global" npm config set cache "D:\ide\nodejs\node_cache"ImportantReplace
D:\ide\nodejswith your actual Node.js installation directory. -
Update the environment variable.
Right-click This PC > Properties > Advanced system settings. In the System Properties window, click Environment Variables. In the Environment Variables window, find the Path variable, select it, and click Edit. In the list of paths, find and change the entry from
C:\Users\<YourUsername>\AppData\Roaming\npmtoD:\ide\nodejs\node_global. -
Verify the change.
Run
npm install jquery -gin Command Prompt. If ajqueryfolder appears in theD:\ide\nodejs\node_global\node_modulesdirectory, the global module path has been changed successfully.
-