'nvm' is not recognized as an internal or external command

avatar
Borislav Hadzhiev

Last updated: Apr 4, 2024
4 min

banner

# 'nvm' is not recognized as an internal or external command

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.

nvm is not recognized as internal or external command

Before installing the nvm-windows package, we have to uninstall any pre-existing Node installations.

If you skip this step (and you have Node.js installed), you'll have conflicting versions and might run into confusing bugs.

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:

  1. Clean the cache in your terminal.
cmd
npm cache clean --force
  1. Open the nodejs.org page and download the Windows installer for the LTS (long-term supported) version.

download node lts version

  1. Start the installer and click Next on the Welcome screen.

node start installer

  1. 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.

node click remove

  1. Click on the "Remove" button again to uninstall Node.js.

  2. You might have to restart your computer if you get prompted.

wait for process to complete

  1. If you have any of the following folders on your machine, make sure to delete them. NVM's generator symlink doesn't overwrite an existing installation directory, even if the directory is empty.
cmd
# ๐Ÿ‘‡๏ธ 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-*
  1. The next step is to make sure you don't have Node and npm in your PATH environment variable.

  2. Click on the Search bar and type "environment variables".

  3. Click on "Edit the system environment variables".

edit system environment variables

  1. Click on the "Environment Variables" button.

click environment variables

  1. In the "System variables" section, select the "Path" variable and click "Edit".

select path and click edit

  1. Make sure to delete references to Node and npm as shown in the screenshot below.

delete from path

  1. Click on "OK" twice to confirm.

  2. Optionally, restart your PC before continuing.

# Install NVM on Windows

To install NVM on Windows:

  1. Open the Releases page of the nvm-windows repository.
  2. Scroll down to the nvm-setup.exe file for the latest release and click on it.

download nvm installer

  1. Accept the license agreement and click "Next".

accept nvm license agreement

  1. Leave the default destination location selected and click "Next".

select destination location

  1. Leave the default symlink directory selected and click "Next".

select symlink directory

  1. Click on the "Install" button.

click on install

The next step is to open PowerShell as an administrator.

To run PowerShell as an administrator:

  1. Click on the Search bar and type "PowerShell".
  2. Right-click on the "PowerShell" application and click "Run as administrator".

run powershell as administrator

Run the nvm ls command to make sure nvm is installed successfully.

PowerShell
nvm ls nvm --version

run nvm commands

If you want to install the latest version of Node.js, use the nvm install latest command.

PowerShell
nvm install latest

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.

PowerShell
nvm use latest

nvm use latest

If you want to install the long-term supported version or another version, first use the nvm list available command.

PowerShell
nvm list available

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.

PowerShell
# ๐Ÿ‘‡๏ธ install the specific version nvm install 18.12.1

nvm install specific version

To use the specific version, issue the nvm use command.

PowerShell
# ๐Ÿ‘‡๏ธ 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.

PowerShell
nvm ls node --version

nvm ls

If you get a permissions error when issuing an 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.

# Additional Resources

You can learn more about the related topics by checking out the following tutorials:

I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.

Copyright ยฉ 2024 Borislav Hadzhiev