However, developers sometimes need to downgrade Node to a previous version when they encounter compatibility issues with dependencies or when a project requires a specific release.
Learn how to downgrade the Node version in Windows and manage multiple Node.js versions on a machine.
- Access to the Windows command prompt (CMD) or PowerShell.
- Administrator privileges.
Downgrade Node Version on Windows
Removing an existing Node distribution and reinstalling a previous version whenever you have a different project is impractical.
The nvm (Node Version Manager) tool enables developers to install different versions of Node side-by-side and switch between these versions via the Windows command line.
Note: Having two concurrent Node distributions, one installed using nvm and another using npm, may lead to compatibility issues. It is recommended to uninstall existing Node versions before installing nvm.
Step 1: Uninstall Existing Node Version
To remove a Node.js version from your Windows system:
1. Type Control Panel in the search box on the taskbar.
2. Open the Control Panel app.
3. Click Uninstall a program in the Programs category.
4. Select the Node.js installation.
5. Click Uninstall.
The Windows Installer proceeds to uninstall Node.js. Follow on-screen prompts to ensure the process runs its course and that the current Node.js version is completely removed from your Windows system.
Step 2: Install nvm on Windows
To install nvm on Windows:
1. Use a browser to access the nvm GitHub repository.
2. Download the latest nvm installer by clicking nvm-setup.exe in the Assets section.
3. Locate the installer on your local machine and double-click to start the installation.
4. Select I accept the agreement.
5. Click Next.
6. Choose an nvm installation path and select Next.
7. Keep the default path or define a custom symlink for the active Node.js version.
8. Click Next.
9. Select Install.
10. Click Finish.
The nvm installation process is complete.
Step 3: Use nvm to Install Node
Managing Node.js versions via nvm requires administrator privileges for the Windows command prompt (CMD) or PowerShell.
To install a specific Node version using cmd:
1. Type cmd in the search bar and select Run as administrator.
2. List the available Node versions using the following command:
nvm list available
Identify the version you want to install and note the version number.
3. To install a specific version, use the following command (replace x.x.x with the version number):
nvm install x.x.x
For example, to install Node.js version 16.14.1, type:
nvm install 16.14.1
The system confirms that the installation is complete.
To install the latest available Node version, enter:
nvm install latest
Note: Every time you use nvm to install a new Node.js version, the tool also installs the corresponding npm version by default.
To install the latest stable version, which is recommended for most users, type:
nvm install lts
To start using the lts version, enter the following command:
nvm use lts
The system confirms the Node version currently being used.
Step 4: Downgrade Node Version
To downgrade a Node version, type the following command::
nvm use x.x.x
Replace x.x.x with a version number.
Note: Ensure that the version you want to use is already installed.
For example, to start using a previously installed version, 16.14.1, enter:
nvm use 16.14.1
You have successfully downgraded the Node.js version on Windows using nvm.
Step 5: Check Current Node Version
To verify the system is using the correct Node version, run the following command:
The version number is shown in the terminal.
To confirm the npm version, type:
The system displays the npm version.
How to Switch Between Node Versions
Before switching between Node versions, list the versions installed on your Windows machine.
1. Use the following command to list installed Node versions:
2. Switch to a different Node version from the list. For example:
nvm use 20.2.0
3. List installed Node versions again to confirm the correct version is actively used:
The asterisk (*) symbol shows which Node.js version the system currently uses.
Now you know how to downgrade and manage Node.js versions on Windows using the nvm tool.
Use this knowledge to quickly switch between Node versions based on project requirements and avoid potential compatibility issues.