Last updated: Apr 4, 2024
Reading timeยท4 min
The error "'nvm' is not recognized as an internal or external command,
operable program or batch file" occurs when we use the nvm
package without
installing it first.
To solve the error, install nvm
on your Windows machine before using it.
Before installing the nvm-windows package, we have to uninstall any pre-existing Node installations.
If you have any global npmrc
configuration files, e.g. at
%AppData%\npm\etc\npmrc
, back them up before continuing.
Follow these steps to completely remove Node.js from your Windows machine before
installing nvm
:
npm cache clean --force
Next
on the Welcome screen.If you have Node.js installed, you will see a "Remove" button.
If you only see installation steps, scroll down to the "Install NVM on Windows" subheading.
Click on the "Remove" button again to uninstall Node.js.
You might have to restart your computer if you get prompted.
# ๐๏ธ delete the following folders (if you have them) 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-*
The next step is to make sure you don't have Node and npm
in your PATH
environment variable.
Click on the Search bar and type "environment variables".
Click on "Edit the system environment variables".
npm
as shown in the screenshot
below.Click on "OK" twice to confirm.
Optionally, restart your PC before continuing.
To install NVM on Windows:
nvm-windows
repository.nvm-setup.exe
file for the latest release and click on
it.To run PowerShell as an administrator:
Run the nvm ls
command to make sure nvm
is installed successfully.
nvm ls nvm --version
If you want to install the latest version of Node.js, use the
nvm install latest
command.
nvm install latest
If you want to use this version, issue the nvm use latest
command, or the
command from the end of your installation message.
nvm use latest
If you want to install the long-term supported version or another version, first
use the nvm list available
command.
nvm list available
You can see the long-term supported version at the top of the LTS column.
Currently, it is 18.12.1
, so I can install the specific version with the
following command.
# ๐๏ธ install the specific version nvm install 18.12.1
To use the specific version, issue the nvm use
command.
# ๐๏ธ use the specific version nvm use 18.12.1
You can use the nvm ls
command to check which nvm
versions you have
installed and which is the currently active version.
nvm ls node --version
nvm
command, you have to start PowerShell or CMD as an administrator and rerun the command.You can view all of the available nvm
commands in
this section of the
package's GitHub repository.
You can learn more about the related topics by checking out the following tutorials: