JavaScript runs most of the interactive elements on websites and mobile applications. JavaScript works perfectly with HTML/CSS and is integrated with most popular browsers. Pure JavaScript is used on the web, and for general JavaScript applications, developers use various runtime environments, such as Node.js.
Node.js is a JavaScript code execution environment. It allows you to use JavaScript as a general-purpose programming language, creating server parts and writing full-fledged desktop applications.
The basis of Node.js is the V8 engine. This engine was developed by Google and is used in the Google Chrome browser. It compiles JavaScript code into machine code that the processor can understand. However, to make JavaScript a general-purpose language, one engine is not enough. So, for example, to create a server part, the language needs to be able to work with files, the network, etc. To solve this problem, developers have added additional capabilities to V8 using their code and third-party libraries. They ended up with a tool that turns JavaScript into a general-purpose language.
Node.js has become popular among developers due to its ability to create server and client parts in the same language, speed, and NPM. In this article, we will tell you how to properly install Node.js on Windows 10/11.
Before installation, you must uninstall older versions of the execution environment if you have them, as it may cause conflicts.
Let's check the system for Node.js versions. To do this, launch cmd (press Win+R, type cmd and press Enter) and run the nvm list command:
C:\Users\Hostman>nvm list
18.9.0
18.8.0
16.17.0
As you can see, we have several versions installed. To delete them:
Run the npm cache clean --force
command.
Go to Add or Remove Programs and remove Node.js.
Reboot the computer.
Remove the following directories if they exist:
C:\Program Files (x86)\Nodejs
C:\Program Files\Nodejs
C:\Users\{User}\AppData\Roaming\npm
C:\Users\{User}\AppData\Roaming\npm-cache
C:\Users\{User}\.npmrc
C:\Users\{User}\AppData\Local\Temp\npm-*
Return to the command line and execute nvm uninstall
for each version from the nvm list
output:
C:\Users\Hostman>nvm uninstall 18.9.0
Uninstalling node v18.9.0... done
C:\Users\Hostman>nvm uninstall 18.8.0
Uninstalling node v18.9.0... done
C:\Users\Hostman>nvm uninstall 16.17.0
Uninstalling node v18.9.0... done
Check that the versions have been deleted:
C:\Users\Hostman>nvm list
'nvm' is not recognized as an internal or external command
C:\Users\Hostman>where node
No files matching the pattern were found
C:\Users\Hostman>where npm
No files matching the pattern were found
Managed solution for Backend development
Node Version Manager or NVM for short is a Node.js version manager. You may need to use different versions of Node and switch between them as you work.
NVM is the most common version manager, but it is not available on Windows and a custom version of nvm-windows is used instead.
Visit the nvm-windows repository on Github.
Download the nvm-setup.exe
installer for the latest version of the manager.
After downloading, install it.
Once the installation is finished, open PowerShell as an administrator and run nvm list available
to see the list of versions available for download:
If your project does not require a specific version, we recommend selecting the latest LTS release to minimize possible issues. If you want to test the new features and improved features, you can download the latest version. However, there is a greater risk of errors when using the newest version.
Let's install the latest LTS. Check the version number in the nvm list available
output and install it using nvm install
:
PS C:\WINDOWS\system32> nvm install 20.13.1
Downloading node.js version 20.13.1 (64-bit)...
Extracting node and npm...
Complete
npm v10.5.2 installed successfully.
Installation complete. If you want to use this version, type
nvm use 20.13.1
In some cases, when installing nvm-windows
, a problem may occur: nvm will not load the NPM package manager. In this case, we recommend using the installation method below.
Go to the Downloads on the official Node.js website.
Select and download the version you need.
Once the download is complete, open the file and the installation will begin.
Follow the installer's instructions.
If you want to use Node.js with Docker, plan to work with the Bash command line, or just love Linux, you might consider installing Node.js in WSL2.
WSL (Windows Subsystem for Linux) is a software layer for running applications created for Linux systems on Windows OS.
This section will contain instructions for installing WSL2.
The WSL2 installation algorithm in Windows 10 depends on the operating system version. To find it out, press Win+R and enter winver
. After this, the following window will open:
If it’s Windows 11, you’re good to go with Method 1. If it’s Windows 10, check the version and build and select the appropriate method.
To use this installation method, you must be running Windows 10 version 2004 and higher (build 19041 and higher) or Windows 11.
In PowerShell, run the following commands as an administrator:
wsl --install
wsl --set-version Ubuntu 2
To check the result, use the command wsl.exe -l -v
:
PS C:\WINDOWS\system32> wsl.exe -l -v
NAME STATE VERSION
* Ubuntu Stopped 2
To use this method, you must have at least Version 1903 or later, with Build 18362.1049 or later.
Run PowerShell as administrator and activate the Windows Subsystem for Linux.
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
Then activate the virtual machine function:
dism.exe /online /enable-feature /featurename: VirtualMachinePlatform /all /norestart
After completing these steps, you need to restart your computer.
When the computer starts, download and install the Linux kernel update package. You can download it here.
In PowerShell, select version 2 of WSL as the main one.
wsl --set-default-version 2
Now let's download some operating system on Linux. You can do this directly from the Microsoft Store app store.
Once the installation is complete, you can log into the console of the installed system through the search menu.
Node.js is a popular development environment used by many large companies: PayPal, Yahoo, Ebay, General Electric, Microsoft, and Uber.
In this guide, we looked at different ways to install Node.js on Windows 10 and 11.