A Step-by-Step Guide to Installing nvm-windows for Node.js Management
NVM (Node Version Manager) and nvm-windows are both version managers for Node.js, but they are designed for different operating systems and have distinct implementations:
- NVM: Originally developed for Unix-like systems (like Linux and macOS), NVM allows users to install and manage multiple versions of Node.js. It's a bash script that modifies the
PATH
environment variable to switch between Node.js versions. - nvm-windows: Specifically designed for Windows, nvm-windows is a separate project that provides similar functionality to NVM but is built with Windows system compatibility in mind. It has a different implementation, using a symlink-based approach to manage Node.js versions, and offers a graphical user interface for version management.
This guide explains how to install and use nvm-windows.
Before installing nvm-windows, uninstall existing versions of Node.js.
Why Uninstall Node.js:
- Version Conflicts: Having a pre-installed version of Node.js can lead to conflicts with nvm-windows. nvm-windows is designed to manage multiple Node.js versions, and a pre-existing installation outside of nvm-windows can interfere with this process.
- Clean Slate: Uninstalling ensures that you start with a clean slate, making it easier to manage Node.js versions through nvm-windows. This helps in avoiding any unexpected behavior or errors caused by remnants of the old installation.
- Path Management: nvm-windows manages the PATH environment variable to switch between Node.js versions. Any existing Node.js installation paths in the environment variables need to be cleared to allow nvm-windows to correctly manage these paths.
By following these steps, you ensure that nvm-windows can effectively manage your Node.js versions without interference from previous installations.
How to Uninstall Node.js:
- Windows Search:
- From the Windows Search in the task bar, search for and then click Add or remove programs.
- Search for "node."
- Click Node.js and then select Uninstall or Remove. Follow the prompts to complete the uninstallation process:
- Check for Remaining Files:
- After uninstallation, check if there are any remaining Node.js files in your system. Common directories to check include:
C:\Program Files\nodejs
C:\Users\[Your Username]\AppData\Roaming\npm
C:\Users\[Your Username]\AppData\Roaming\npm-cache
- If these folders still exist, delete them.
- After uninstallation, check if there are any remaining Node.js files in your system. Common directories to check include:
- Environment Variables:
- From the Windows Search in the task bar, search for "Environment" and then click Edit the system environment variables.
- In the System Properties window, click on the Environment Variables button.
- Check both the User and System variables for any references to Node.js or npm and remove them if found.
Install nvm-windows
- Go to the nvm-windows GitHub repository.
- Download the nvm-setup.exe file under the latest release.
- Run
nvm-setup.exe
file. This will launch the nvm-windows installer. - Follow the installer prompts. It will ask you to choose the directories for installing nvm-windows and where to store the Node.js versions. You can probably accept the defaults.
- Once the installation is complete, restart your command prompt or terminal for the changes to take effect.
- To verify that nvm-windows is installed, open a new command prompt or terminal and type
nvm version
. This should display the version of nvm-windows you have installed. - After installation, you might need to configure your system's environment variables, although the installer typically handles this.
- Ensure that the path to nvm-windows is added to your system's
PATH
environment variable. This is usually done automatically by the installer. - To install a specific version of Node.js, open your command prompt or terminal and type, for example,
nvm install 20.10.0
(replace20.10.0
with the desired version). - To switch between installed Node.js versions, use
nvm use <version>
, e.g.,nvm use 20.10.0
. - After installing a Node.js version, you can check it by typing
node -v
in your command prompt or terminal. This should display the currently active Node.js version.
You should now have nvm-windows installed on your system, allowing you to manage multiple Node.js versions easily. Have fun!
Related Articles
- A Step-by-Step Guide to Installing nvm-windows for Node.js Management (this article)
- Node.js and Node Package Manager (npm)