Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Node.js, PHP and APIs

NVM for Windows says access denied when you install or switch Node.js

ErrorAccess Denied

Short answer

NVM for Windows switches versions with a symlink, and Windows usually needs administrator rights to create one. Run PowerShell or Command Prompt as Administrator first. If it still fails, the symlink folder may already be a real directory, or an older Node.js install is in the way.

  • Applies to NVM for Windows (Community Build), Windows 11
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Open a new shell with Administrator rights and run the debug command. NVM for Windows 1.1.11 and later has it, and it reports PATH conflicts.

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

    1. 1Access denied right after nvm install or nvm use in a normal windowThe shell is not running as AdministratorFix
    2. 2nvm use fails even in an Administrator shell, and the symlink path exists as a normal directoryThe symlink location is already a real folderFix
    3. 3nvm use finishes, but node -v shows another version, or nothing changesA separate Node.js installation still owns the PATHFix
    4. 4Access denied or exit 5 although the shell is elevated, with the nvm root under C:\Program Files; or exit 145 or exit 32 with 'being used by another process'Node.js versions are stored in a protected folder or a locked directoryFix

What does the error look like?

  • Access Denied
  • exit 5
  • exit 1

Cause 1 of 4

The shell is not running as Administrator

1Check

NVM for Windows documents that it runs in an Admin shell, because Windows normally needs administrative rights to create the symlink that nvm use relies on.

([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)

2Fix

Close the window and start PowerShell or Command Prompt with Run as administrator, then repeat the command.

nvm use 22.11.0

3Verify

node reports the version you asked for.

node -v

Confirmed by github.com

Did this fix it?

Cause 2 of 4

The symlink location is already a real folder

1Check

NVM for Windows documents that setting the symlink location to an existing directory fails, because a symlink cannot overwrite a physical directory. An earlier manual Node.js install in that path does this.

Get-Item "C:\path\to\your\symlink-folder" | Select-Object FullName, LinkType
echo $env:NVM_SYMLINK

2Fix

If LinkType is empty, the folder is a real directory. Uninstall the Node.js that created it, or point NVM_SYMLINK at a path that does not exist yet, then run nvm use again.

nvm use 22.11.0

3Verify

The same folder now shows a link.

Get-Item "C:\path\to\your\symlink-folder" | Select-Object LinkType, Target

Confirmed by github.com

Did this fix it?

Cause 3 of 4

A separate Node.js installation still owns the PATH

1Check

The project recommends uninstalling existing Node.js versions before using NVM for Windows. When another install sits earlier in PATH, nvm use can appear to do nothing.

where.exe node
nvm debug

2Fix

Uninstall the standalone Node.js from Windows Apps, open a new Administrator shell, and select a version again.

nvm list
nvm use 22.11.0

3Verify

where.exe lists only the NVM symlink path for node.

where.exe node
node -v

Confirmed by github.com

Did this fix it?

Cause 4 of 4

Node.js versions are stored in a protected folder or a locked directory

1Check

Windows requires administrator rights to write to C:\Program Files. A different failure, exit 145 or 32, appears when a terminal or Explorer window has the version folder open or a node.exe process is still running.

nvm root
Get-Process node -ErrorAction SilentlyContinue

2Fix

Keep the Node.js versions in an unprotected folder such as C:\nvm4w, and run nvm use from a neutral directory such as C:\ after stopping running Node processes.

cd C:\
Stop-Process -Name node -ErrorAction SilentlyContinue
nvm use 22.11.0

3Verify

nvm use completes with no error.

node -v

Confirmed by github.com

Did this fix it?

How do I stop it coming back?

  • Keep an Administrator terminal profile just for nvm commands.
  • Uninstall any standalone Node.js installer before installing NVM for Windows.
  • Choose a symlink folder that does not exist when you install NVM for Windows.
  • Run it from CMD or PowerShell; the project notes that some other shells ignore the administrator prompt.

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

Back end

ng serve says it cannot determine the project or target

Cannot determine project for command.

The Angular CLI looked through angular.json for a project that defines the target you asked for (serve, build, test) and found none, or found several and could not pick one.

3 causes, each with a fix

Back end

ng serve cannot find the dev-server builder package

Could not find the implementation for builder @angular/build:dev-server

The builder named in angular.json (for example @angular-devkit/build-angular:dev-server) is looked up as an npm package starting from the workspace root.

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