Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Next.js and React

nvm for Windows installs but npm cannot be found

ErrorCannot find the npm file

Short answer

On Windows the npm that nvm gives you only works when nvm can create its symlink and no older Node.js sits earlier in PATH. Remove the old install, enable Windows developer mode, pick a symlink folder that does not exist yet, install a version with nvm install, and use CMD or PowerShell.

  • Applies to nvm-windows 1.2.x, Windows 11, Node.js 22
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Run the built-in diagnostic in an Administrator CMD or PowerShell window. It reports symlink and PATH problems that explain why npm is not found.

    nvm debug
    nvm list
  2. 2Match what you see, then jump to its fix

    1. 1nvm list shows no version, or no star next to the one you expectThe Node.js version is not installed, or none is selectedFix
    2. 2node -v shows a version you did not select with nvm useAn older Node.js install is earlier in PATH or blocks the symlinkFix
    3. 3Exit 1, exit 5 or Access Denied from nvm use or nvm installnvm cannot create the symlink because of permissionsFix
    4. 4nvm use appears to work but admin-required steps are ignored (Cygwin, mingw, cmder, ConEmu, Hyper)You are in a shell nvm-windows does not supportFix

What does the error look like?

  • Cannot find the npm file
  • 'npm' is not recognized as an internal or external command

Cause 1 of 4

The Node.js version is not installed, or none is selected

1Check

npm comes with each installed Node.js version. If the install failed, or you never ran nvm use, there is no npm to find.

nvm list
nvm current

2Fix

Install a version, then select it.

nvm install 22.12.0
nvm use 22.12.0

3Verify

Open a new terminal and print both versions.

node -v
npm -v

Confirmed by github.com

Did this fix it?

Cause 2 of 4

An older Node.js install is earlier in PATH or blocks the symlink

1Check

Windows searches PATH in order, so a leftover Node.js directory listed before nvm's symlink wins. An existing folder at the symlink location also blocks nvm; the README says it will not overwrite one, even an empty one.

where node
dir "C:\Program Files\nodejs"

2Fix

Uninstall the old Node.js (back up your global npmrc first), delete leftover folders such as C:\Program Files\nodejs, and use nvm debug to confirm the symlink path is free. If NVM_SYMLINK points at an existing folder, point it at one that does not exist yet.

nvm debug
nvm use 22.12.0

3Verify

where node lists only the nvm symlink path.

where node
npm -v

Confirmed by github.com

Did this fix it?

Cause 3 of 4

nvm cannot create the symlink because of permissions

1Check

The wiki names Windows developer mode as the most common fix, because switching versions creates a symlink. It also advises against keeping Node.js installs in protected folders such as C:\Program Files.

nvm root
nvm debug

2Fix

Turn on Windows developer mode (or run the shell as Administrator), and keep nvm's root in a folder like C:\nvm4w rather than Program Files.

nvm root C:\nvm4w
nvm install 22.12.0
nvm use 22.12.0

3Verify

nvm use finishes without an access error and npm -v prints a version.

npm -v

Confirmed by github.com

Did this fix it?

Cause 4 of 4

You are in a shell nvm-windows does not support

1Check

The wiki lists Cygwin, mingw, cmder, ConEmu and Hyper as unsupported, because they ignore UAC prompts that nvm needs.

echo %ComSpec%

2Fix

Run the same commands in the regular Windows Command Prompt or PowerShell.

nvm use 22.12.0
npm -v

3Verify

npm -v prints a version in the supported shell.

npm -v

Confirmed by github.com

Did this fix it?

How do I stop it coming back?

  • Uninstall any existing Node.js before installing nvm-windows.
  • Install nvm-windows on the C: drive; the wiki lists installs on other drives failing silently in one release.
  • Keep nvm root and the symlink folder outside Program Files.
  • Close the terminal when a new install does not appear, and reopen it.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Web apps

tsconfig rejects allowImportingTsExtensions

An error that allowImportingTsExtensions needs noEmit or emitDeclarationOnly

allowImportingTsExtensions lets files import each other with .ts or .tsx extensions, and TypeScript only allows it together with noEmit or emitDeclarationOnly.

2 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.